- Home /
Vector3.Slerp normal
So I've started to mess around with slerping, and I understand how SLerp works where Vectors are treated as directions instead of as world positions. I have everything working the way I want it to, except I don't know how to set the normal of the Slerp. Its best to show a pic:
We need to see the code you are using in order to help you with your problem.
It is a bit hard to figure out what's wrong here without seeing you code and having coordinates labeled in the picture. There is no normal for Slerp, but Slerp is lazy. It takes the shortest arc between the two points.
Unfortunately, there are infinite amounts of the same distance arcs between two points. Here is the Slerp invoke:
transform.position = Vector3.Slerp(startDirection, endDirection, timePast / time) + center;
but that shouldn't really change anything. In the image, the red arc and the white arc are obviously the same distance, Unity just chooses the red one for some reason.
Answer by robertbu · Apr 14, 2014 at 01:34 AM
There are only an infinite number of same-distance arcs when the two end points are on a line that passes through the origin. That is when they are 180 degrees apart when measured from the origin. If your start position is even a fraction of a degree along the arc, then you only have one shortest arc.
Ah I see what you are saying now, so I should basically revise the start position by a $$anonymous$$iscule amount to influence the 'normal' of the arc, thanks! If you post that comment as an answer, ill mark it as correct.
I converted the comment to an answer. You'll want to test it first to make sure the answer solves your problem. I know it works with Quaternion.Slerp() and I believe I've tried it with Vector3.Slerp() as well. Note if it always 180 degrees between them, and if the vectors are the same length, you can just use Quaternion.AngleAxis() to rotate one vector 180 degrees ins$$anonymous$$d.
thank you, your answer was precious, i didn't know why only one of my objects had it's arch movement flipped upside down
Your answer
Follow this Question
Related Questions
Why does the raycast hit only objects/faces of a certain rotation? 1 Answer
local rotation per axis between frames? 1 Answer
How to use the lerp function with rotation? (C#) 1 Answer
How do I add force to an object based on my Camera's cureent Y rotation (C#) 2 Answers
rotation x changes all angles? 3 Answers