I’m stumped. I don’t know why my character has a short teleport while walking. I printed some variables for debugging. Transform.forward and Time.deltaTime are consistent, so I don’t know what causes the jump in rb.position/transform.position (they are exactly the same always).
When I turn on “Is Kinematic”, the tiny teleport disappears, but then my character goes through walls. Does this mean an invisible force is being applied to my character??
// FixedUpdate for movement through force
void Update ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
//walk animation
if (Input.GetAxis ("Vertical") > 0.2) {
//start where foot stopped
foreach (AnimationState animState in anim) {
animState.speed = 1;
}
GetComponent<Animation> ().Play ("Walk");
//move position
print ("rb: " + rb.position);
print ("tf: " + transform.position);
rb.MovePosition(rb.position + transform.forward * Time.deltaTime * 2);
} else
//stop mid animation
foreach (AnimationState animState in anim) {
animState.speed = 0;
}
}