• Unity
  • Is raycast(not raycast2D) reacts with spine bounding box?

Hello,

I'm making a kind of gun-shooting game with spine characters.

I'm considering to make bullet's trail with Unity raycast but it seems not react with spine bounding boxes.

Any advices?

Related Discussions
...
  • Изменено

Unfortunately general Unity Physics rules apply here, since BoundingBoxFollower creates and updates a PolygonCollider2D collider, it will only interact with the 2D physics subsystem. Creating a 3D MeshCollider instead (an extruded polygon) is also not trivial, since it needs triangulation of the outline's vertices to work.

Easier solutions would be to either:

  • a) Manually create 3D BoxColliders and let them follow bones to interact with the 3D Physics raycast.
  • b) Since your Spine objects seem to be on the same Z plane: calculate the ray-intersection point of the ray and this plane, and then use Physics2D queries to determine if e.g. a circle lies within the 2D collider.

Oh, thanks very much for sharing, great find! I didn't know that this method was really casting a 3D ray through the cap-area of 2D colliders!

Check how it works!

Very nice! 🙂 Now add a hit animation! 8)