- Home /
Question by
RudyPyro · Mar 25, 2018 at 08:40 AM ·
rotationquaternion
Why is my the rotation not similar?
I am currently working on a project where you can move buildings around a planet, The problem is that when I try to do so the rotation of the parent of the object that I am moving is not correct, It is not looking at the posision where the raycast hit the planet.
There is something wrong with this bit:
if (Physics.Raycast(ray, out hit))
// check if the hitted object is the planet
if (hit.transform.gameObject.tag == "Planet")
{
_direction = (hit.point - transform.parent.position).normalized;
_lookRotation = Quaternion.LookRotation(_direction);
transform.parent.rotation = _lookRotation;
transform.position = hit.point;
transform.localPosition = BeginPosition;
}
else
{
print("Please click on a valid spot");
}
Comment