I have a tower object with two colliders - a box to represent its actual physics, and a sphere to represent it’s range. I want to test for the box, not the sphere, however both exist on the same layer(as they’re part of the same object). Is this possible at all?
Tower
Box: Not trigger.
Rigidbody: Kinematic
Sphere: Is Trigger
Other object:
Box collider: Not trigger
Rigidbody: not kinematic
Relevant Code:
var moveVect : Vector3 = Vector3(1, 0, 0);
var moveSpeed = 32.0;
function Update ()
{
var hit : RaycastHit;
if(Physics.Raycast(transform.position, moveVect, hit, 1))
{
if(hit.collider.GetType().ToString != "SphereCollider")
{
print(hit.transform.name + " @ " + hit.transform.position.ToString());
transform.Rotate(Vector3.forward, 90);
Debug.DrawLine(transform.position, hit.transform.position, Color.white);
}
}
transform.Translate(moveVect * moveSpeed * Time.deltaTime);
}