Game Development Reference
In-Depth Information
_isFall = true;
}
}
if (_isGrounded) {
if (_isFall) {
_animator.SetTrigger("Ground");
_isFall = false;
} else {
var animationStateInfo : AnimatorStateInfo =
_animator.GetCurrentAnimatorStateInfo(0);
if ((rigidbody2D.velocity.y < 0f) &&
(animationStateInfo.IsName("Base Layer.Jump"))) {
_animator.SetTrigger("Fall");
_isFall = true;
}
}
}
}
}
// C# user: (Put the code inside the class)
void FixedUpdate () {
if (!_gameEnd) {
#region Setting player horizontal movement
_animator.SetFloat("Speed",
Mathf.Abs(_horizontalInput));
float xSpeed = Mathf.Abs(_horizontalInput *
rigidbody2D.velocity.x);
if (xSpeed < maxSpeed) {
rigidbody2D.AddForce(Vector2.right *
_horizontalInput * moveForce);
}
if (Mathf.Abs(rigidbody2D.velocity.x) > maxSpeed)
{
Vector2 newVelocity = rigidbody2D.velocity;
newVelocity.x = Mathf.Sign(newVelocity.x) *
maxSpeed;
Search WWH ::




Custom Search