stop camera when collision withh a wall ????

Hi…

in my game I put the camera at the main character , so if it rotate or move the camera will do that too .

my problem :

if the player stand beside the wall then rotate, the camera will go throw the wall , what should I do to let the camera move to the player ( above or behind it ).

thanks

1 Answer

1

You have to do a ray cast. That’s pretty tricky.

var hit: RaycastHit;
	  
if (Physics.Linecast (vecA, vecB, hit))
      {
      Debug.Log("I hit something");
      return hit.point;
      }

It really depends on what you have so far.
This post helped me alot when i needed it:
http://forum.unity3d.com/threads/16949-WOW-Camera-Movement/page2