|
Hey guys i have two things to ask,
I need some help -_-
Thanks
(comments are locked)
|
|
OnControllerColliderHit() is only called on the GameObject containing the CharacterController Component, not on the colliding rigidbody, so you'd have to do it the other way round, detecting if your character hit something and then determining if it was a cube/crate whatsoever. Oh and the parameter for OnControllerColliderHit is of type ControllerColliderHit. ;) Thanks!, i add the code to the Character Controller but i know that isnt enough, what exactly do i need to do more? im not exactly sure about " ControllerColliderHit "
Jan 26 '10 at 02:28 PM
Trouch
And yeah, i'am really new to this
Jan 26 '10 at 02:28 PM
Trouch
not sure what you want to do, so it's hard to tell. The function in your script that is supposed to handle your collision events is written as "function OnControllerColliderHit(other:ControllerColliderHit)" ControllerColliederHit contains the information you need to determine what you hit. You can look up in the scripting manual what information is actually supplied.
Jan 26 '10 at 02:34 PM
StephanK
(comments are locked)
|
|
to use triggers you should mark your colliders as triggers. check the "is trigger" box in collider's inspector. then there are three events that you can use. OnTriggerEnter will be called when a collision starts and OnTriggerExit will be called when the collision ends and two objects don't overlap. OnTriggerStay will be called once in each frame between OnTriggerEnter and OnTriggerExit. stay means two colliders are in a collision. after your object fall in to the other one, it should go back and exit from other's collider region and then come back in to call OnTriggerEnter again.
the function takes one argument that tells you who is colliding with you. Ah ok thanks for explaining, but how do i assign a key for the trigger, e.g. ' Once " E " is pressed the collision code runs '
Jan 26 '10 at 11:50 AM
Trouch
(comments are locked)
|
This code is attached to a cube that has a collider, When i use the standard First Person Controller to touch the box ( walk over to it ), Nothing happens I know this code works only if its a moving object And yes my First Person Controller has the tag " Player " Thanks for help so far, and i'am sorry for posting two questions in one.
(comments are locked)
|
|
It's a bit hard to tell you what you're doing wrong if you don't say what you are actually doing... (code). What you should look at is if all your objects have some sort of Collider attached to it, and that at least one of them is a dynamic (not kinematic) rigidbody. Otherwise Collisions won't work. I suspect that you are using a CharacterController to move your character, so OnCollisionEnter() won't be called. Try using the OnControllerColliderHit() for Collisions involving your character. Triggers are different from Collisions. To receive trigger events you have to mark your Collider as Trigger. Then use the OnTriggerEnter/Stay/Exit methods of the Collider.
(comments are locked)
|
|
"how do i assign a key for the trigger" You'll need to manually check whether the key is pressed or not in your OnTriggerEnter code using Input.GetKey() or a similar function.
(comments are locked)
|

it's java script and not java.
Mazzarx, generally you shouldn't post two unrelated questions in one here on UnityAnswers. Post them one by one as separate questions instead. Thanks!