- Home /
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?
Answer by Garrett Chase 3 · Mar 05, 2010 at 01:35 AM
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
Answer by Garrett Chase · Jan 13, 2010 at 04:07 AM
Haha nevermind, I just figured out. You just use the Physics.IgnoreCollisions function.
Answer by Fries · Feb 16, 2010 at 05:11 AM
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
Your answer
Follow this Question
Related Questions
Problem with melee collision 3 Answers
Player shaking when colliding with objects 3 Answers
Collider going through walls with box collider.. 1 Answer