In FixedUpdate.
I checked, the rigidbody.velocity .y is always 0 , and the Physics.gravity is always -9.8, and nobody collid with rigidbody
void FixedUpdate()
{
// rigidbody.WakeUp();
detectKey();
updateAniByState();
System.Diagnostics.Debug.Assert(rigidbody.position.z == -0.5);
print("rigidbody.velocity = " + rigidbody.velocity + " rbody = " + rigidbody);
}
void detectKey()
{
if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
{
moveTowardRight();
}
else if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
{
// rigidbody.transform.Translate(Vector3.left * SPEED * Time.deltaTime);
moveTowardLeft();
}