Quantcast
Channel: Questions in topic: "follow"
Viewing all articles
Browse latest Browse all 536

[Maths] How to make an object follow a curve?

$
0
0
Hello, I am trying to make an object follow a curved line, and I am using the equation - ***y = ax^2 + bx + c*** but I do not fully understand it yet and am looking for a bit of help with that. Currently I am inputting these values: - ***a*** = Gravity (9.81) - ***x*** = time - ***b*** = power (5) - ***c*** (start pos of object.y - 0) I think I am implementing this wrongly in code or misunderstand the equation. Help with either would be great. void Update () { ballPos = ballMove (t);// t is my time input - x in the equation transform.Translate (ballPos); t = t + 0.001f; // finding a new time value } public Vector3 ballMove (float timestep) { float time = timestep; Vector3 newPos = Vector3.zero; float a; float b; float c; a = gravity * (time * time); b = power.y * time; c = startPos.y;//65 newPos.y = a + b + c; b = power.x * time; c = startPos.x;//0 newPos.x = b + c; b = power.z * time; c = startPos.z;//0 newPos.z = b + c; return newPos; } Thanks for your time.

Viewing all articles
Browse latest Browse all 536

Trending Articles