Ragdoll support for NPC(s).
Fix: https://github.com/webaverse/app/issues/1891 Follow: https://github.com/webaverse/app/pull/2610 Sibling PR: https://github.com/webaverse/app-wasm/pull/36
https://user-images.githubusercontent.com/10785634/161391728-004c5a87-92fa-48c4-9ced-9f7dc067b404.mp4
https://user-images.githubusercontent.com/10785634/161393407-7f82ab21-c754-4842-89ce-6093daf816b2.mp4
The github compare https://github.com/gonnavis/app/compare/RagdollPr...RagdollNpcPr seems wrong.
Compared to RagdollPr branch, only changed these codes:

Another question: are the ragdoll bones theoretically movable by grabbing the avatar VRM bones to re-position? VR posing is a future feature and it would be nice if we can delegate the restitution logic for posing to the ragdoll bones system.
We should also think hard about using
xstate. We shouldn't just use it for ragdolls, but for everything (if that is the approach), otherwise the code would be really inconsistnet.
Yes I want to use xstate as state-manager for everything, especially character animation/combat system.
I'll working on this afterwards.
So if we are using
xtatewe need to make sure it is fast for game loops (e.g we should know for a fact that it doesn't allocate any memory during the loop, because that will cause unfixable GC performance problems later). Do you have 100% confidence there is absolutely no allocations from reading the library's code, and allocations will never be added in the future?If there is not 100% confidence in this fact we should not use this library.
I used xstate in my personal game project. I feel it's very powerful and handy, and the performance seems good. Each character in it built with a complex xstate state-machine,
But I really not sure whether it allocate any memory during the loop. I'll try to confirm by reading the source code and get help from the community.
Another question: are the ragdoll bones theoretically movable by grabbing the avatar VRM bones to re-position? VR posing is a future feature and it would be nice if we can delegate the restitution logic for posing to the ragdoll bones system.
Yes, I think so. I'll try to make a demo.
Hello @avaer, I feel I need more time to prove the performance of XState, I'll try in other PRs. So for this PR, I used state variables instead of XState. https://github.com/webaverse/app/pull/2731/commits/ceeedf4977d9722b330e00b4dcc62d721fcc2d6d
Another question: are the ragdoll bones theoretically movable by grabbing the avatar VRM bones to re-position? VR posing is a future feature and it would be nice if we can delegate the restitution logic for posing to the ragdoll bones system.
Do you mean something like this? I added the grabbing logic in the commented codes for testing. https://github.com/webaverse/app/pull/2731/commits/591a6f73948a7d3593072ffcfc39301ae8571bff
https://user-images.githubusercontent.com/10785634/161782121-01dee374-a71c-4f2f-a1dc-e059c3ce8c0f.mp4
Do you mean something like this?
Kind of! That demo is really cool!
I meant more being able to pose the avatar in a specific way (like moving the hands up, but keeping the spine in place to create a pose).
It looks like we might be able to do it, but it's probably best to ship this first and make that a separate PR.
This PR need a rebase.
@avaer Solved conflicts of this PR, and sibling PR too https://github.com/webaverse/app-wasm/pull/36 .
Separated/Created ragdoll.js. https://github.com/webaverse/app/pull/2731/commits/2ec63f19407c2c0ada5d58618e1462e41aec843d
A few more wasm-related comments.
@gonnavis where we at with this? still needed, or been replaced?
@gonnavis where we at with this? still needed, or been replaced?
Still needed, but need a lot of code structure refactor, and should be changed to z-targeting branch, I'll keep working on this.
Closed in favor of https://github.com/upstreet-labs/app/pull/262