I have a game object that is created and placed through script and it gets a component with a function that should rotate it to face a target, and I’m using this piece of code:
Vector3 dir = alvo.position - eu.position;
Vector3 forward = eu.forward;
forward.y *= -1;
Vector3 rotation = Vector3.RotateTowards(forward, dir, 1, 0.0f);
transform.rotation = Quaternion.LookRotation(rotation);
where alvo = target (in portuguese) and eu = me (in portuguese) = gameObject
and it works the axis z points to the target, but it makes the mesh to be turned 90 degrees in the axis y
=(
is there a way to tell unity that the canon is the front of the mesh, not the side of it?