- Home /
Add delay to Fixed Update?,How to add a delay to moving object in Fixed Update?
i'm new to coding, but is there a way to add an initial delay to a moving object with the following code. Thank you!
void FixedUpdate()
{
if (lookAtTarget)
{
Utils.SetAxisTowards(useSide, transform, target.position - transform.position);
}
rigidbody2D.MovePosition(Vector2.Lerp(transform.position, target.position, Time.fixedDeltaTime * speed));
}
,I'm new to coding, but I've tried everything to add a delay to the following object's movement. Nothing works. Help :)
public class FollowTargetDelay4seconds : Physics2DObject { public Transform target; [Header("Movement")] public float speed = 1f; public bool lookAtTarget = false; public Enums.Directions useSide = Enums.Directions.Up;
void FixedUpdate()
{
if (lookAtTarget)
{
Utils.SetAxisTowards(useSide, transform, target.position - transform.position);
}
rigidbody2D.MovePosition(Vector2.Lerp(transform.position, target.position, Time.fixedDeltaTime * speed));
}
}
Comment