- Home /
ignore select collider
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);
}
Answer by Chris D · Jun 17, 2011 at 04:54 PM
Just make the sphere a separate GameObject and assign it as child to the tower. This way you should be able to set it's layer separately and/or just identify it by it's unique G.O. name/tag/whatever.
Yeah, that was my plan, figured it would be worth checking for a more elegant method all the same.
Thanks.
Your answer

Follow this Question
Related Questions
Can't click gameobject when over another trigger? 1 Answer
Change multiple object layers 0 Answers
Ignore Collision Layer Ignores also other layers 1 Answer
Modifying the HeadLook Controller in C# 2 Answers
Changing layers affect triggers? 1 Answer