#Getting triangle/part of collider hit in entity collision

1 messages · Page 1 of 1 (latest)

stiff summit
#

Is there some way of determining what part of a collider was "hit" in a collision event between two entities, one a "unit" and the other being a projectile, with the goal of the unit having several damageable areas (such as left/bottom/front/a weak spot between the three/ect)
the only thing i was able to find that did something similar was RaycastHit.triangleIndex() but there does not seem to be an equivalent for unity physics, and none for a collider based collision
while i could just inaccurately calculate something close based on direction i would prefer a more accurate solution

cerulean lake
#

Although when I did this a year or so ago there was something weird with ColliderKeys being invalid, so be prepared that it might be confusing if it hasn't been fixed yet

#

This assuming that by "part of collider" you mean that you have a CompoundCollider with child colliders in it

stiff summit
#

not at the moment, im just using basic spheres for prototyping right now

cerulean lake
#

Then I'm not sure by what you mean "which part was hit"? A sphere collider doesn't have parts

#

Are you specifically trying to find the triangle + point where the collision hit?

stiff summit
#

yes, but moreso an area (top, underside, top left corner, ect), and im not sure if cutting up a collider into a few dozen is a great way to go about it

errant rivet
#

if you are just dealing with like a capsule or a cube you could just setup volumes to represent areas in your authoring and then compare the hit position on the collider to those volumes transformed by your world position, which might be easier than dealing with a multi collider setup