0 votes

This is confusing me no end! inside a physicsprocess 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.

in Engine by (12 points)

1 Answer

0 votes

Hello Corin,

Every time velocity changes, you need to re-calculate velocityPercentage. Could you check that you're doing this.

by (388 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.