Rotate object's local up towards a vector.

Hey I’m working on a 2D game and am trying to figure this out.

What Im trying to do is when an object collides with another Object A’s local up (Y) axis points towards the position of Object B.

Any help with the math on this one :D?

You need to set the “up” to be the vector from one object to the other:

    var direction = (objectHit.transform.position - objectA.transform.position).normalized;
    objectA.transform.up = direction;


    objectA.transform.rotation = Quaternion.FromToRotation(Vector3.forward, Vector3.up) * Quaternion.LookRotation(direction);