|
Im using the OnCollisionEnter-function to detect a collision between an enemy and the player, but it will only record a collision when they are both moving towards eachother. When for instance the player jumps on top of the enemy, nothing is triggered, and the same goes for when the player runs in to the enemy from behind. Code:
(comments are locked)
|
|
Are you using Character Controller? If so, have you tried to use OnControllerColliderHit instead? No, I havent tried that but will - thanks. But is that function only triggered from the Players point of view (ie when attached to the Player, which is the object with the Character Controller) or can it be triggered from the enemy, which in this case only has a collider (no character controller)?
Mar 22 '10 at 06:29 PM
Daniel 1
On the enemy you should still use OnCollisionEnter/OnTriggerEnter.
Jun 10 '10 at 01:29 PM
rlbaldi
(comments are locked)
|
|
Ok, since I needed the Enemy (which lacks a Character Controller since collisions between two character controllers seem to be a bad idea according to most posts Ive read) to be the detecting party, what I needed to do was to add (not replace) another collider to the player. I then tagged it, made it a trigger, and made a OnTriggerEnter-call detect it from the enemy's script.
This enabled the enemy to detect hits with the player even when the collision came from behind or from above.
(comments are locked)
|
|
,u can make an empty game object and just put something like a gimzo to let u know where u wanna hit him and place it the place u want but not on the player just infront or beside and use it as trigger so once it enters this area its triggered whatever for a cutscene kill or whatever.
(comments are locked)
|
|
ok i answered it but i didnt notice it was year earlier
(comments are locked)
|
|
I have a very similar issue! When I jump on a collider with my character(has a rigidbody) from top, it triggers the OnCollisionEnter function. However, If I slider onto the collider from a side (so that the character doesn't fall from top on it), it does nothing. Is there any way to check when I'm on the collider when I slide onto it from a side? PS: the collider is a simple platform and the character has a cube collider and rigidbody. I need to apply new velocity OnCollisionEnter regardless of which angle I fall onto the collider from.
(comments are locked)
|
