- Home /
Question by
sarahfoojn · Nov 02, 2021 at 04:52 AM ·
movementpingpong
Mathf.PingPong not working properly, object supposed to move left to right but instead spawns at a completely different location and z and y axis keep on randomising.
void Update() {
target1.transform.position = new Vector3(target1.transform.position.x, Mathf.PingPong(Time.time*4,4.08f+2.56f)+4.08f , target1.transform.position.z);
target2.transform.position = new Vector3((Mathf.PingPong(Time.time*4, 3.00f +2.60f)+3.00f), target2.transform.position.y, target2.transform.position.z);
target3.transform.position = new Vector3(target3.transform.position.x, Mathf.PingPong(Time.time * 10, 4.08f + 2.56f) + 4.08f, target3.transform.position.z);
}
target 1 and target 3 are working fine though.
thank you for taking the time to help!
Comment