I'm trying to get a sphere collider working with my camera and the terrain without success. So far I've tried attaching a sphere collider + rigidbody, collider, toggling IsTrigger in both cases, etc... the problem is that when the cameras collider hits the terrain it never seems to trigger a OnCollisionEntry or OnTriggerEntry (I'm overriding both to try and catch the event).
I have even just tossed debug output to see that the collider is moving with the camera, etc... all seems well, I'm not sure what the issue is here.
Any ideas how to make a camera collider work with terrain?
Edit: Added Camera Control Script Code.
enum Axis {MouseXandY, MouseX, MouseY}
var Axis : Axis = Axis.MouseXandY;
var sensitivityX = 15.0;
var sensitivityY = 15.0;
var minimumX = -360.0;
var maximumX = 360.0;
var minimumY = -60.0;
var maximumY = 60.0;
var rotationX = 0.0;
var rotationY = 0.0;
var lookSpeed = 2.0;
function OnTriggerEnter (other : Collider)
{
print( "OTE" );
}
function OnCollisionEnter(collision : Collision)
{
print( "OCE" );
}
function Update ()
{
// allow for WSAD control of the camera
var x = Input.GetAxis( "Horizontal" ) * Time.deltaTime * 10.0;
var z = Input.GetAxis( "Vertical" ) * Time.deltaTime * 10.0;
transform.Translate ( x, 0, z );
// handle mouse look, only mouse look when right mouse button is used
if( Input.GetMouseButton( 1 ) )
{
// Read the mouse input axis
rotationX += Input.GetAxis( "Mouse X" ) * sensitivityX;
rotationY += Input.GetAxis( "Mouse Y" ) * sensitivityY;
// Call our Adjust to 360 degrees and clamp function
Adjust360andClamp();
transform.localRotation = Quaternion.AngleAxis( rotationX, Vector3.up );
transform.localRotation *= Quaternion.AngleAxis( rotationY, Vector3.left );
}
}
function Adjust360andClamp ()
{
// Don't let our X go beyond 360 degrees + or -
if (rotationX < -360)
{
rotationX += 360;
}
else if (rotationX > 360)
{
rotationX -= 360;
}
// Don't let our Y go beyond 360 degrees + or -
if (rotationY < -45)
{
rotationY = -45;
}
else if (rotationY > 30)
{
rotationY = 30;
}
// Clamp our angles to the min and max set in the Inspector
rotationX = Mathf.Clamp (rotationX, minimumX, maximumX);
rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
}