I have a transform and I want it to look at another. I could use lookAt, but it makes the forward points to it and i want the upwards to point to it.
Important detail: Those 2 transforms (me, and target) doesn’t exists at the beginning they are created by scripts, so I can’t simply make a prefab or something like that i need a script solution
Here are a couple of ways. Say the object you want to point has ‘target’… the transform of the object you want to point at:
transform.up = target.position - transform.position;
Here is another way:
transform.rotation = Quaternion.FromToRotation(transform.up, target.position - transform.position) * transform.rotation;