# Gravity Linv problem?

Okay, so here’s my script for fps movement in my game. My problen is that I fall EXTREMELY slowly. How do I fix this?

import bge
from bge import logic
from bge import events
cont = logic.getCurrentController()
obj = cont.owner
key = logic.keyboard.events

WKEY = key[events.WKEY]
AKEY = key[events.AKEY]
SKEY = key[events.SKEY]
DKEY = key[events.DKEY]

xForce = 0.0
yForce = 0.0

if AKEY == 2:
xForce = -20

if DKEY == 2:
xForce = 20

if WKEY == 2:
yForce = 20

if SKEY == 2:
yForce = -20

if xForce != 0 and yForce != 0:
xForce = xForce / 1.414
yForce = yForce / 1.414

obj.setLinearVelocity([xForce, yForce, 0.0], 1)

Thanks!

My Way of solving this (and I think that many People here handle it that Way), is applying an additional Z Velocity while in Air.

If Player is not on the Ground (RayCast):

if player.localLinearVelocity[2]&gt;-11:
player.localLinearVelocity[2]-=0.14

If you set a velocity you override any other velocity. Especially the velocity that is the result of the gravity forces.
If you need this influences you can:

• calculate the velocities by your own
• use forces rather than velocity

Well there’s the problem. I want to move in mid-air but also fall… and force absolutely SUCKS for character movement as you increase speed. My original way to fix it (an idea) was just to always have a pressure on -Z axis, but that doesn’t work since the player then can’t move.

Just set the Z velocity to the objects Z velocity;

z_vel = object.getLinearVelocity().z

object.setLinearVelocity(x, y, z)

Maybe I misunderstood this Statement, but as I understood it, I must disagree: If only the Z Velocity is set, then only the Z Velocity is affected – X and Y Velocity can still be changed independently.

@ hamstaq: The Z Speed of falling Objects does increase, that is a physical Fact (but as you want to move in mid-air, I guess that you are not at all up to such physical Stuff). However, as the Speed Increase shan’t be exaggerated, I also set a Limit in my Example.
You still can the Z Velocity only if the Player touches Ground – then the Velocity won’t drag the Player to the Ground and immobilize him.

If you set the full vector of the velocity, you override whatever the velocity was before.

If you read the velocity vector, change the vector and apply this new value you get the “recalculation method”. This means you get a vector relative to the current one.
Your example post#2 and Agoose’s example post#5 do exactly that. And I think they are the solution of the issue.

The code from the top post just replaced velocity without caring it’s current value (constant 0 at the Z value).

Why is it still falling?
Because the physics calculates and applies the gravity forces after the SCA logic completed for the frame.
This results in the forces at the beginning of the drop. They are tiny but noticeable.