Can we make work on game objects only at specific conditions like for an activeTween or similar?
thanks!
You need to be way more specific with your question.
Three.js doesn’t have a physics engine, game objects or a tweening library so at the very minimum you need to let us know what you’re using for all of these, and what you’ve tried so far.
It’s a fairly common thing to need to do, so you should also google it, chances are someone already asked the same question and got answers.
I did google but nothing worked the way I intend. I’m using cannon js for physics and what I’m trying to achieve is gravity acting on the body when the tween is active on it!
What does happen if initially the mass of the body is 0 and when tweening is activated the mass is changed to some non-zero value?
In this demo (with physijs, not cannon) the plates have 0 mass. When hit, their mass is set and they respond to gravity by falling down:
https://boytchev.github.io/CourseVAX/LecturesBG/06/E0618-Floor-of-tiles.html
No effect at all. I updated the mass while the tween is active to ensure the body keeps falling until it collides with something, but it doesn’t work that way. The body falls upto the distance I tweened to and not further. I checked your example but is there anything in cannon that I can achieve it?
If you are going to use a physics library, for example Ammo.js, all movement logic must be done with variables from the Library. for example, instead of THREE.Vector3, Ammo.btVector3 is used to move the physical object.
The Three.js mesh that is attached to the physical object only follows the movement of the calculation made in the physics part.
You can use Tween, but you have to update the physical body, applying impulses or forces, not on the mesh.
https://didisoftwares.ddns.net/7/index.html