LookAt Transform

Any suggestions how to get a camera to look at the position another (instantiated) object collides with another object? …not sure how to get the collision location, and assign it as a look at position of the camera.

Thankyou.

On the instantiated object you can use the OnCollisionEnter function so that “something happens” when it collides with another object. Here is the generic example Unity - Scripting API: Collider.OnCollisionEnter(Collision)
This also gives you an example on how to find the point of collision.
So if you have the contact point, you may direct the camera to LookAt that point.
(You must first establish a reference to the camera from within the other object’s script)

// suppose your camera is named MyCamera
// pos = contact point (follow given example)
GameObject cam = GameObject.Find(“MyCamera”);
cam.transform.LookAt(pos);

So far so good?

Apart from that, you may have to handle the case of multiple collision points (all at once) what happens then?
Unless you have spherical objects in which case it is more difficult to have many collision points.

hope it helps

1 Like

Thank-you, I appreciated the expertise!

No problem!
I am not an expert by the way :slight_smile: but thanks!
Did you make it to do what you wanted?

Got it to work, thanks again.