- Home /
LineRenderer: 2D Parabola in 3D Space
Hey all,
I've been working on creating a program that can create a 2D parabola in 3D space (for arcs, and such) but am having some trouble with the third dimension. I've been using this code to generate the parabola:
int i = 0;
while (i < accuracy) {
float z = interval * i;
float y = ((a * (z * z)) + (b * z) + c);
Vector3 position = new Vector3(x * i, y, z + arcCaster.position.z);
arc.Add(position);
i++;
}
...where z is a public float and a, b, and c, can be found by:
a = power;
b = power * h * -2;
c = (power * (h * h)) + maxHeight;
All this is based on the vertex form of the quadratic equation:
a(x-h)^2 + k
or
power(x–HValue())^2 + maxHeight
float HValue () {
return Mathf.Sqrt ((arcCaster.position.y - maxHeight) / (1/-power));
}
Now this gives me a nice arc:
But I cannot rotate this arc. It needs to be able to point in the direction of the cube. My initial thought was to put the positions in a line renderer, set it to local space, and then make the line renderer a child of the cube. But then I realized that I needed those positions for other things, and the positions of the line renderer were in local, not world space.
If I could get the positions of the line renderer and then convert it to world space that would be great. But looking around it doesn't seem like that's possible. Any solutions to this?
Your answer
Follow this Question
Related Questions
How to have player fire projectile in a parabola? 4 Answers
position coins in parabolic path 1 Answer
Triying to make a character take knockback in a parabolic motion in 2D. 0 Answers
How to shrink a line renderer 1 Answer
How to put a gameobject at the position of the line formed by a LineRenderer? 1 Answer