Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Corin |
This is confusing me no end! inside a _physics_process I have a velocity, if i multiply it by -0.1 and add the result to itself then you end up basically grinding to a halt (or with a very very low/limited movement speed)
Here is the code:
var playerMovement = Vector3(1,0,1) # A Constant Movement Vector
var playerGravity = Vector3(0,-9,0) # A Constant Gravity Vector
var velocityPercentage = velocity * -0.1
playerVector =+ playerMovement + playerGravity + velocityPercentage
velocity = move_and_slide(velocity+playerVector, Vector3(0,1,0))
I was trying to emulate simple air resistance on a kinematic body, however once it became apparent that my velocity was decided by my air resistance and my air resistance was decided by my velocity i did the above test.
Now i have absolutely no idea how to continue - I dont understand how my velocity can be outweighed by ten percent of itself especially when considering my velocity is constant?!?!?
The moment i remove the “velocityPercentage” from the “playerVector” variable, everything runs fine.
I’m embarassed to admit i’ve spent 3 days on this, everywhere i look explains that i need to use my velocity to decide my air resistance - this looks utterly impossible in godot based on what im seeing above.