I have an OnTrigger collider under my player that is supposed to be used to kill an enemy when it touches that collider. It usually works, but the problem is that if the player jumps and falls down really fast, the OnTrigger won’t activate immediately and as a result, the player will get damaged as well as the enemy. What is the best way that I can take care of this problem?
Maybe a raycast? You could also check when the player hits the enemy where they are located and see if they were still “squished”
I did try a raycast, but it did not seem to be as accurate in damaging the enemy as the collider is.
What’s the shape of the collider? You may be able to use a BoxCast, SphereCast or CapsuleCast if your collider’s shape matches one of those, or maybe just approximate your character’s shape with one of those.
Using a boxcast seems to be working so far since I have not been able to replicate my problems yet. It is just about the same size as the box collider, so I’m wondering if I should either make the boxcast bigger or move the hitbox further away from the boxcast so that it will not cause the player to get hurt.
idk about the collider part I have trouble with that too, but you are accessing a damage script right? That the player take the damage only?
If you move or rotate the rigidbody script with anything except .MovePosition or .MoveRotation, you will certianly open yourself to the possibility of missing trigger/collide calls.
Any type of casting (box or otherwise) does not have this issue. But if you directly do transform.position = newPosition;
or such, you’re going to miss collisions/triggers.