Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CharacterContactListener: add OnContactPersisted and OnContactRemoved #1027

Closed
eliasdaler opened this issue Apr 1, 2024 · 4 comments
Closed

Comments

@eliasdaler
Copy link

It would be nice for CharacterContactListener to be more similar to ContactListener and have OnContactPersisted and OnContactRemoved (so that you can send events when the character exists the sensor, for example).

@eliasdaler
Copy link
Author

And while we're at it, the docs for CharacterContactListener::OnContactAdded say:

Called whenever the character collides with a body. Returns true if the contact can push the character.

Which seems outdated since the method doesn't return anything.

@jrouwe
Copy link
Owner

jrouwe commented Apr 1, 2024

The comment was wrong indeed, I fixed that.

The CharacterVirtual doesn't keep track of previous contacts in the same way as the normal simulation does, so it would require a bit of rework to support this especially since there are many function calls you can do on the character (Update, ExtendedUpate, WalkStairs) that modify it's collision state and to the library it is not obvious when the user is 'done' moving the character.

As a user of the library it shouldn't be hard to track this though. You can store the existing contacts through GetActiveContacts before you start modifying the state of the character and then in the OnContactAdded callback you can check if it is a new contact / after you finish modifying the character you can compare the old state with the new state to generate contact removed events.

@eliasdaler
Copy link
Author

As a user of the library it shouldn't be hard to track this though. You can store the existing contacts through GetActiveContacts before you start modifying the state of the character and then in the OnContactAdded callback you can check if it is a new contact / after you finish modifying the character you can compare the old state with the new state to generate contact removed events.

I see, thanks! If it's hard to implement, then it's probably not worth it.

I just found OnContactRemoved pretty handy for regular bodies, since I didn't need to do the manual tracking. But I guess I can track previous contacts myself as you've explained. :)

@bryanedds
Copy link

bryanedds commented Dec 30, 2024

I'd like to explore the addition of these feature. If the user can avoid this sort of manual bookkeeping (and the bugs that come with it), it might be better to OnContactAdded a built-in feature for jolt character contact listeners.

EDIT: 'Reopened' here - #1427

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants