x


Ignore Collision Temporarily

I need an object to have no collision with the player while is is being scaled. This is because while it is growing, it is causing to launch the player. I have tried using :

if(transform.localScale.x < 1  &&  Growing)
{
    transform.localScale.x += GrowTime;
    transform.localScale.y += GrowTime;
    transform.localScale.z += GrowTime;
    Physics.IgnoreCollision(gameObject.FindWithTag("Player").transform.collider , this.collider);
}

while the variable growing is set to true. But once it is set to false, the player can still not collide with the Object. Is there any way to make the object start checking for collision again once growing is set to false?

more ▼

asked Mar 21 '12 at 07:59 PM

AJspartan gravatar image

AJspartan
1 5 5 6

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

You should be able to use Physics.IgnoreCollision to do this, as you've got. I'd use the third parameter to be explicit about it. Based on the documentation, you should be able to do IgnoreCollision(collider1, collider2, false) to regain collision. I have used this in the past, so should work unless something is up with 3.5.

If that doesn't work, the documentation also mentions that you can Deactivate/Reactivate the collider objects to clear the IgnoreCollision state. See here: http://unity3d.com/support/documentation/ScriptReference/Physics.IgnoreCollision.html

Good luck!

more ▼

answered Mar 22 '12 at 01:31 AM

kromenak gravatar image

kromenak
1.6k 23 29 41

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2495
x1873
x1697
x1278
x388

asked: Mar 21 '12 at 07:59 PM

Seen: 992 times

Last Updated: Mar 22 '12 at 01:31 AM