x


How can I specify what I want something to collide with?

I am coding a game, and I want to check whether or not the main character's sword is colliding with stuff. I have a capsule collider attached to it, and seems to work well. I have a script that sends anything the sword collides with flying through the air. The problem is that randomly the sword will collide with my character and send me flying off the terrain forever. Is there any way to prevent this from happening, or somehow specify what to collide with?

more ▼

asked Jan 13 '10 at 04:05 AM

Garrett Chase gravatar image

Garrett Chase
25 2 2 3

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

3 answers: sort voted first

Sure here is the code I was using:

function OnTriggerEnter(other : Collider) {

Physics.IgnoreCollision(GameObject.Find("Main Character").collider, collider);
Debug.Log("I Hit Something!!!!");

}

Hope that helps

more ▼

answered Mar 05 '10 at 01:35 AM

Garrett Chase 3 gravatar image

Garrett Chase 3
47 7 7 7

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

Haha nevermind, I just figured out. You just use the Physics.IgnoreCollisions function.

more ▼

answered Jan 13 '10 at 04:07 AM

Garrett Chase gravatar image

Garrett Chase
25 2 2 3

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

Garret Chase - do you think you could post that script i am making a similar game yet i dnt no anything about scriptin. plz post it THNKS

more ▼

answered Feb 16 '10 at 05:11 AM

Fries gravatar image

Fries
2 4 4 4

(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:

x2482
x1682

asked: Jan 13 '10 at 04:05 AM

Seen: 1356 times

Last Updated: Jan 13 '10 at 04:05 AM