Question by
jaredlevi · Mar 30 at 09:00 PM ·
updatefixedupdateupdate functionupdate problem
fixed update is not being called
Fixed update is not being called! I don't understand nothing prints at all!
public static Transform CurrentlySelectedObject;
private bool Moving = false;
private void FixedUpdate()
{
Debug.Log("Moving :" + Moving);
if (Moving == true && CurrentlySelectedObject != null)
{
Rigidbody2D Rb = CurrentlySelectedObject.GetComponent<Rigidbody2D>();
Vector2 direction = (Vector2)CurrentlySelectedObject.position - mousePosition;
direction.Normalize();
Rb.MovePosition(Rb.position + direction * Time.fixedDeltaTime * 100);
Debug.Log(Rb.position + " " + direction);
}
}
Comment
Answer by jaredlevi · Mar 30 at 09:45 PM
I moved this script to another object. Now this function is called a minimum of zero and a maximum of three times before it stops completely? I thought the issue might have been caused by my fixed time step but that is set to the default 0.02. I have no idea what could be causing this.