transform.LookAt Help

Hi All,

Looking for a little help with the transform.LookAt function. I have an object that is rotated so that it’s ‘up’ is not world up. I want to have that object look at a point in world space and to be able to manipulate that point so that ‘y’ is ‘up’. However, when I move that point upwards along the 'y axis and then try and look at that point using transform.LookAt(targetPos, new Vector3(0,1,0)) my object does not rotate upwards in the world ‘Y’ direction.

I’m sorry if I’m not explaining this very well, but I don’t entirely understand what’s going wrong. Would I need to somehow translate the movement of my point into something that is compatible with the objects ‘up’ and then use the objects ‘up’ in the LookAt function?

Thanks
Ray

you might want to try:

transform.LookAt(targetPos, new Vector3(0,1,0),Space.World)

EDIT: I am not entirely sure if this is possible for lookat though. I will look into it more

You can also make the rotated object a child of another gameobject so you can hide the internal rotation.

Thanks for the replys. Is it quite common to do this? It seems that LOOKAT would only work if the rotation of the object is such that the local ‘forward’ matches the object’s forward, but it seems that’s not always the case. Am I wrong, or am I making this seem more complicated than it is?