+1 vote

I have a kinematic 2d which moves with MoveAndSlide(velocity, Vector.Up) in _process
Lag doesn't change horizontal moving speed and it moves always with the same speed but jump height is always changing with fps
How to solve that?
Also there isn't such a problem while i use the code with _physicsProcces .but i can't use that because it causes lag when a there is a lot of nodes with that script in tree

void Jump()
{
velocity.y=-JumpForce;
}
void Move()
{
velocity.y+= Gravity;
velocity.x=MovementSpeed;
}
public override void _Process(float delta)
{
velocity=MoveAndSlide (velocity, Vector.Up)
}
Godot version Godot 3.5.1
in Engine by (15 points)

1 Answer

0 votes

I too am a noob so I may be getting this wrong, please correct me if so:

  • delta is the time since the last frame

  • this means your movement speed will change based on FPS

  • you need to multiply the variable you are calling in process() by delta to make sure it is occurring per second, and not per frame. velocity = delta * MoveAndSlide(..)

by (35 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 Frequently asked questions and 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 [email protected] with your username.