- Home /
On Trigger Enter, Collide with object, specific collision
In a game I am writing I want to create "safe zones" and theses are like beacon towers (which having a sphere around them which are a trigger). I want the player to be able to run through them but the monster cant.
I have tried things like, when the player enters a bool variable sets true so player is safe, then the ai script doesnt run because they are safe, when they leave it goes to false and the monster can chase after them again, but that does not work. I have tried to switch off the AI script when the Player enters the Trigger but that doesnt work either.
So is there a way I can have specific collision, so the player can run through a OnTriggerEnter or a OnCollisionEnter but the monster cannot?
I have tried and looked at:
http://answers.unity3d.com/questions/528831/collision-with-specific-object.html http://unity3d.com/learn/tutorials/modules/beginner/scripting/enabling-disabling-components http://answers.unity3d.com/questions/39748/disable-script-from-code.html http://answers.unity3d.com/questions/26844/enabledisable-specific-components.html
None of these work for me.
TL;DR I want my player to be able to move to a place where the monster cant. (Only knowledge in C# can use Java if I must but rather C#)
Answer by flaviusxvii · Apr 25, 2014 at 05:08 PM
Thank you so much. I didn't know about layers with this I can finsih my game as the deadline is in 2 weeks. Thanks.
Your answer
Follow this Question
Related Questions
Collision problem in C# 4 Answers
OnTriggerEnter with exact spot of collision 2 Answers
Colliding two GameObjects 1 Answer
Keep doing something while colliding 1 Answer