- Home /
Sum Of Two Motions?
Hi, I am trying to make a gameobject's path of motion by adding together two separate motions on two axes, so Motion A moves back and forth between two points on the X axis and Motion B does the same on the Z axis (It's 2d so Y remains static). The two motions are of an arbitrary period.
I've tried using the following code and, while the two motions do both cycle up and down ok, they seem to be applied to the object sequentially and the object moves in boxy shapes rather than the nice smooth curves I was hoping for.
function Update () {
transform.position = Vector3(Mathf.PingPong(Time.time * 250,500), transform.position.y, Mathf.PingPong(Time.time * 350,500));
}
Can anyone point me in the right direction please?
Many thanks
Your answer
Follow this Question
Related Questions
How do i make an object move unpredictably? 0 Answers
Moving an Object - The right way. 2D 1 Answer
Instantiated object isnt moving 1 Answer
Check if 2 objects positions are close enough 2 Answers
Problem with a motion script 0 Answers