I’m trying to compensate for some differences in mass when dealing with RigidBody3D collisions but some of the collisions involved come from the player (or the player’s hands in VR) which are CharacterBody3D nodes which do not have a “mass” variable, so my question is simply: When a CharacterBody3D produces a collision impulse on a RigidBody3D, what is the mass used in that calculation? I’m assuming 1.0 Kg since that’s the default for RigidBody3D objects, but I’d like to be certain… or is it more complicated than that?
As far as I know, it is treated as if the CharacterBody3D had an infinite mass. That also explains why there is no impulse effect coming from RigidBody3D to the CharacterBody3D.
Here’s a similar problem that someone had, maybe you can check the solution provided there?
Curious… that almost seems to contradict what I’ve been experiencing…
The way my game works in VR is that the player is able to equip things in their hands and can subsequently drop/throw them. The object equipped in a hand is simply a frozen RigidBody3D which is unfrozen if the player lets go of it to throw it. However, if the player hits another RigidBody3D in the world with the frozen one in their hands the object in the world goes FLYING with tons of force, yet if the player were to hit the same RigidBody3D with their bare hands, which are CharacterBody3D nodes, the object in the world goes flying a much shorter distance. I thought this would be related to mass differences given what I’ve experienced using the apply_central_impulse() command, but if it’s true that CharacterBody3D is treated as infinite mass then what I’m experiencing here must be something entirely different and thus compensating for it may not be so simple… either that or the behaviour of freezing a RigidBody3D as a child of a CharacterBody3D has unintended side-effects…?
I am not entirely familiar with how the physics engine handles this, but I would imagine that rapidly moving the frozen rigid body inside the active one would accumulate a massive impulse. The physics engine typically manipulates both objects’ velocities to separate them, but the frozen constraint causes this desperate separation behavior.
An alternative to freezing the rigid body that I have used before is using a strong damped spring to snap the rigid body to the desired transform. The object may lag behind the visual arm a bit but the rigid body would act physically accurately as everything would be done using forces.
I don’t think the forces are building up; If the player lets go of an object they are holding onto the game first delays the actual unfreezing of the object by one physics tick, as this improves the feel in VR, and then simply unfreezes the object and reparents it to the world, allowing its forces in that moment to move it appropriately if it’s flung into the air with speed and/or angle, or simply dropped nonchalantly. The collision flags/masks are set up so that the CharacterBody3Ds used for the player’s hands do not collide at all with the RigidBody3D objects carried in those hands. (And it’s easy to tell when I forget to set the flags correctly because the behaviour of tossing something will be very incorrect.)
Besides which, I kind of want to reduce the effect of ALL player actions directly upon physics objects if I can, while not affecting the forces of the physics objects hitting each other, but since CharacterBody3D does not have a mass variable the simplest approach I’m considering is monitoring when the CharacterBody3D nodes make contact with other physics objects and then countering the impulses produced with inversed and reduced impulses, but I can’t do that without knowing the finer details of mass in these calculations.