- Home /
OnTrigger events on CharacterController in Unity 3
With moving project to Unity 3 detection of trigger collisions with CharacterController start working strange. There is one object with box collider which is trigger and other object with CharacterController. And events OnTriggerEnter and OnTriggerStay happen only if the character is moving. If it stands still there are no collisions. In Unity 2.6 absolutely the same project works fine.
Where could be problem?
Answer by Landon · Nov 04, 2010 at 04:55 AM
I got the same problem! If the CharacterController game object stoped, others can not detect it.
Is there anybody can help us?
You guys may want to upvote the question so it gets more attention.
Answer by barbur · Feb 02, 2011 at 03:45 PM
I have the same problem!! Any news on this one?
You guys may want to upvote the question so it gets more attention.
Answer by 1stIssue · Sep 21, 2011 at 02:46 PM
okay, so I'm gonna write my script down, which works. I'm standing inside a trigger, and everytime I'm pressing "E" or pushing a button, I can do it again, so it pops up again.
private var showDialog:boolean = false ; private var keyPressed:boolean = false ; private var doQuest:boolean = false ; public var enemy:GameObject;
function Update () { if(Input.GetKey(KeyCode.E)) { keyPressed = true ; } }
function OnTriggerStay (collisionInfo : Collider) { if(collisionInfo.gameObject.tag == "Player") { showDialog = true ; } }
function OnTriggerExit () { showDialog = false ; keyPressed = false ; }
function OnGUI() { GUILayout.BeginArea(Rect(20,80,200,200)); if (showDialog&&!doQuest&&keyPressed){ GUILayout.Label("Hallo, ich heisse Manfred!"); GUILayout.Label("Wie ich sehe, wirst du verfolgt. Soll ich meinen Roboterkollegen ausschalten?"); if (GUILayout.Button("Ja, bidde.")){
doQuest=true;
keyPressed = false ;
enemy.GetComponent("AIEnemy").enabled = false;
enemy.GetComponent("Animation").animation.Play("idle");
}
if (GUILayout.Button("Nein, ich mach das schon.")){
keyPressed = false ;
}
}
if (showDialog&&doQuest&&keyPressed){
GUILayout.Label("Wenn du willst, kannst du ihn jetzt treten, er wehrt sich nicht ;)");
if (GUILayout.Button("Na dann mal los.")){
keyPressed = false ;
}
}
GUILayout.EndArea();
}
But, the basic premise of the initial question was that that didn't work!
Your answer
Follow this Question
Related Questions
Bullets colliding with Character Controller 3 Answers
How to fix the position of a character when grabbing a rope? 1 Answer
CharacterController with BoxCollider 1 Answer
How to have other (any) Objects smoothly push a Character Controller? 1 Answer
How do I detect when two CharacterControllers collide? 0 Answers