ErdongChen-Andrew / CharacterControl

Floating Capsule Character Controller (Rigibody control)
https://character-control.vercel.app
MIT License
378 stars 52 forks source link

Add names to character colliders, for better collision or intersection indication #11

Closed Seanmclem closed 7 months ago

Seanmclem commented 7 months ago

I was recently using a cuboidCollider with onIntersectionEnter and exit. I found the character to trigger the event more than once on each enter/exit. Because it has colliders on the model, and on the Ecctrl component itself. By adding a name property to each one, especially the Ecctrl one, we can now detect or differentiate exactly which one caused the event to fire. So if we want to detect a single event, we can exclude those that don't have the character-body-capsule-collider name, for example.

These names would show up in onIntersectionEnter > event.colliderObject.name

vercel[bot] commented 7 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
character-control ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 28, 2023 1:32am
ErdongChen-Andrew commented 7 months ago

Thanks for your contribution @Seanmclem ! However, the default ecctrl collider is just one capsule, and it only triggers enter event once I believe. For specific models or collider use cases, users can name their own colliders to indicate the desired event.

Seanmclem commented 7 months ago

Thanks for your contribution @Seanmclem ! However, the default ecctrl collider is just one capsule, and it only triggers enter event once I believe. For specific models or collider use cases, users can name their own colliders to indicate the desired event.

Right, but the included capsule collider of the library should be able to identify itself. Instead of me, only being able to identify additional colliders added through models. Because, in that case, the included capsule collider would always be nameless.

I only included the updated name of the separate model as an example. I can remove it if that makes it more clear.

ErdongChen-Andrew commented 7 months ago

Emm.. make sense. So you need a way to only identify the ecctrl collider, right? If you could only include name for the capsule collider, I will proceed with merging it into the main 👍

Seanmclem commented 7 months ago

@ErdongChen-Andrew ok done