Apply forces to only parent entity rigidbody

I have an odd issue where the child rigidbodies of the wheel in my project have the force meant only for the parent object applied to them. This causes the models on the child entities to distort in weird ways and it just looks plain ugly. The script I’m using to rotate the wheel is here:

var Spinner = pc.createScript('spinner');

Spinner.attributes.add('manager', {type: 'entity'});

// initialize code called once per entity
Spinner.prototype.initialize = function()
{
    this.paused = true;
};

Spinner.prototype.spin = function()
{
    this.paused = false;
    this.entity.rigidbody.angularVelocity = new pc.Vec3(0,0,100);
};

// update code called every frame
Spinner.prototype.update = function(dt) 
{
    if(this.paused)
    {
        return;
    }
};

Is there a way I can ensure that only the parent object has the forces applied to them, but the child entities rigidbodies still move with the models without distorting the models?

Entities with rigid bodies/collision should not have children with rigid bodies/collision for this reason :slight_smile:

1 Like

The rigid body/collisions themselves are fine. I’m just going to assume what you mean is that an entity with a rigid body/collision should not have children with models and collisions/rigid bodies.

An entity with a rigid body and/or collision should not have any child entities that also have a rigid body and/or collision regardless of any other components that they may or may not have.

To further extend this, no entity with a rigid body and/or collision should be a child of another entity that is moved at runtime.

So i take it the best solution would then be to make all rigid bodies I want to apply force to children of an empty game object?
For example, instead of my hierarchy looking like:
Main Rigid Body
-Child Rigid Body
-Child Rigid Body
-Child Rigid Body

It should look like:
Empty Entity
-Main Rigid Body
-Child Rigid Body
-Child Rigid Body
-Child Rigid Body
-Child Rigid Body

Or compound them together, which up until now I guess I was completely misunderstanding.

Yes, that is correct (assuming Empty Entity isn’t moved at runtime).

If you look at the ragdoll example again, you can see all the entities with rigidbodies are on the same level of hierarchy.