Page 1 of 1
Applying downwards force
Posted: Mon May 14, 2012 5:14 pm
by al9191
In our game, the player character moves around the world. When the player goes up a ramp, it takes a while for them to drop to the ground, therefore you can move through the air for quite a distance before it drops to the floor. (The gravity of the space is set as 9.81.)
If I increase the gravity it messes up all of the player motion motor settings. I also tried increasing the mass of the player (it is currently 2f, but I tried 30f). But even with higher mass and re-tuning the motion motor settings. It still took a while to float down to the floor.
What can I go about doing to make the player drop faster, to prevent players floating off in the air onto objects they shouldn't be able to get onto.
Re: Applying downwards force
Posted: Mon May 14, 2012 5:20 pm
by Norbo
Is there a large LinearDamping manually set on the character body?
Assuming there is no external force or damping slowing the character's fall, the correct approach is to increase the acceleration of gravity. Increasing the mass of an object does not make it fall faster because gravity is an acceleration (i.e. gravitational force scales with mass).
If this player character is not a CharacterController/SphereCharacterController, but rather some kind of object controlled with a SingleEntityLinearMotor or similar, the problem is that the motor controls all three linear degrees of freedom and will fight against gravity. To fix this, use an approach which doesn't fight against gravity. One simple option is to control only the two horizontal axes.
Re: Applying downwards force
Posted: Mon May 14, 2012 5:40 pm
by al9191
On the player there is:
- A SingleEntityAngularMotor set in servo mode, that controls the rotation of the model.
- LinearAxisMotor set in VelocityMotor mode, that controls X direction movement.
- LinearAxisMotor set in VelocityMotor mode, that controls Z direction movement.
These motors are attached to X and Z directions, therefore they shouldn't be controlling Y direction are they?
How would I go about increasing gravity acceleration? Is that what happens purely by increasing Gravity set in the Space?
Thanks very much!
Re: Applying downwards force
Posted: Mon May 14, 2012 6:20 pm
by Norbo
These motors are attached to X and Z directions, therefore they shouldn't be controlling Y direction are they?
If the motor axes are attached to the local space of the entity rather than the world space axes, they could influence motion along the world Y axis. The axis is attached to connection A in the constraint. If connection A is null (i.e. it connects to the special 'world' entity), then the axis will never change. If it's the mobile entity, it will change.
Making them aligned with the world space might complicate handling, though. It may be easier to move over to direct velocity control without constraints or to use something like a customized version of the character's HorizontalMotionConstraint.
How would I go about increasing gravity acceleration? Is that what happens purely by increasing Gravity set in the Space?
Yup, the Space.ForceUpdater.Gravity is the gravitational acceleration. Note that there's nothing special about applying gravity in this way- you can accomplish the same thing by changing the velocity incrementally, since that's exactly what it does. It's just so common that it's baked into the force updater.
Re: Applying downwards force
Posted: Mon May 14, 2012 6:36 pm
by al9191
Ok the X and Z LinearAxisMotors have null for ConnectionA. So what does this mean with respect to floating downwards and gravity?
Re: Applying downwards force
Posted: Mon May 14, 2012 6:48 pm
by Norbo
If the player falls at a slower rate than other objects, that means there is some force or damping slowing the fall.
If there truly is no force or damping stopping the character from falling and the falling appears too slow, that means gravity needs to be stronger.
Re: Applying downwards force
Posted: Mon May 14, 2012 6:49 pm
by al9191
Ah ok thanks. I understand. I think the player falls at same speed, I will increase gravity.