Hi all. I’m developing a game in first person. I created a rope following this example.
The next step was to write the code so that the character could grab onto the end of the rope. When the button is pressed, the end of the rope is attached to the mesh of the hands and for some reason begins to shake chaotically. Any ideas what could be the reason?
Sorry if I’m doing something wrong, this is my first time asking a question on a forum.
Creating ropes in wires file. Attaching to a hand in the hands file in the positionBigItem method. Selecting an item on the H key
Adding @carolhmj and @Cedric our physix experts
Hello! Are you able to reproduce just the rope attachment part on a separate PG?
Sorry for the long answer, the difference in the hour poles played here
Here is the playground, my fault for not attaching it right away
Please don’t worry about taking the time you need for an answer, we all have our own time zones and rest days and we believe in respecting them And thanks for the Playground! I’ll be taking a look at it ASAP.
Hey there! Had a chance to play with the PG, and found that using the
syncWithBone method to sync the physical body of the rope end with the hand bone works well: attaching rope example | Babylon.js Playground (babylonjs.com) (I simplified the example a bit to make it easier to see)
Hello! Thanks for the feedback, but I’m afraid this method doesn’t work for me. I need the body to stick to the hand and when moving, the rope moves with it. I could call this method every frame, but isn’t there a more elegant way? I hope I’m not too annoying)
No worries, it’s a valid question I don’t think there’s a way around calling syncWithBone every frame, or at the very least doing some manual synchronization of the bone with the impostor every frame, as we need to get the absolute transforms of the bone to synchronize it with the physical body. @Cedric might have a better idea of how to do it through.
Just to be sure, you have a physcalized rope and you want to attach a mesh.
will the mesh be physicalized as well so you can add a constraint ?
if not, then it’s a matter of changing space and I can help with the offset computation.
Yes, I probably need the second option, because I was not going to add physics to the hands
In that case, you’ll have to compute the offset from the character root to the hand. This vector is the hand position in root spac.
Then, each frame, transform the vector by the rope end matrix (or quaternion + translation): it will be the character root in world space.
Thanks for the advice, I’ll try this!