Object Collision ?

I am using this script for FLYTHROUGH CAMERA.I want to collide this camera to the object.Even if my object’s Generate Colliders is on,camera is not colliding.What should i do???

following is the script

var lookSpeed = 15.0;
var moveSpeed = 15.0;

var rotationX = 0.0;
var rotationY = 0.0;

function Update ()
{
rotationX += Input.GetAxis(“Mouse X”)*lookSpeed;
rotationY += Input.GetAxis(“Mouse Y”)*lookSpeed;
rotationY = Mathf.Clamp (rotationY, -90, 90);

transform.localRotation = Quaternion.AngleAxis(rotationX, Vector3.up);
transform.localRotation *= Quaternion.AngleAxis(rotationY, Vector3.left);

transform.position += transform.forwardmoveSpeedInput.GetAxis(“Vertical”);
transform.position += transform.rightmoveSpeedInput.GetAxis(“Horizontal”);
}

Awaiting…please reply.

Why don’t you try parenting this camera to an empty game object, then add a collision component to the new empty game object. Adjust the collider to suit your needs, etc.

This should do the trick.

Thanks i3D for yr reply…Ok i have tried this…but no luck…its entering into the objects…

transform.position += transform.forward*moveSpeed*Input.GetAxis("Vertica l");
transform.position += transform.right*moveSpeed*Input.GetAxis("Horizonta l");

this might be your problem, the transform might be moving a bit too fast, for the physics engine to detect the collision… try making the collider on that new GameObject larger, and decrease the speed of the moving camera, see if it still ignores collision.