- Home /
(Picture for Clarity) How do you click on an object, and from that hit point, calculate a direction vector, and then make that direction vector be the upwards direction of an object?
Hi,
How do you click on an object, and from that hit point, calculate a direction vector, and then make that direction vector be the upwards direction of an object? So the hit.point is now on top of the object?
Current code:
var dirVector = hit.point - surface.transform.position;
PlanetObjects.transform.rotation = Quaternion.FromToRotation(Vector3.forward, Vector3.up) * Quaternion.LookRotation(dirVector.normalized);
PlanetObjects.transform.rotation = Quaternion.Euler(PlanetObjects.transform.rotation.eulerAngles.x, PlanetObjects.transform.rotation.eulerAngles.y+90, PlanetObjects.transform.rotation.eulerAngles.z);
This is completely incorrect, but if any thoughts or insight of this issue would be greatly appreciated.
Best, Ciera
[1]: /storage/temp/79424-planet.png
Your answer
Follow this Question
Related Questions
Rotate a GameObject [set front] 1 Answer
How should I rotate a 2D unit vector by X degrees? 1 Answer
Set rotation based on 2 points problem 1 Answer
Rotate but keep direction 1 Answer