0 votes

I'm new to use godot engine and I also friendly with Unity so I prefer to use C# as scripting language.

I'm trying to move player via key input.
I applied Rigidbody2D Node to player and I use this code to move player.

var t = false;
if (Input.IsActionPressed("ui_right") && (t = true))
    //AddCentralForce(Vector2.Right * MovingBias);
    LinearVelocity = new Vector2(MovingBias, LinearVelocity.y);
if (Input.IsActionPressed("ui_left") && (t = true))
    //AddCentralForce(Vector2.Left * MovingBias);
    LinearVelocity = new Vector2(-MovingBias, LinearVelocity.y);
if (!t) LinearVelocity *= Vector2.Down;
if (Input.IsActionPressed("ui_up")) 
    //AddCentralForce(Vector2.Up * 5);
    LinearVelocity = new Vector2(LinearVelocity.x, -20);

//RotationDegrees = 0;

I enter this code to _IntegrateForces to avoid cross-thread issue.

Also, I made my custom map with Tilemap.

My issue is this.
When I press up arrow, it works fine. But in right/left arrow on tile, Player sometimes stuck on when collision changed.
This is the issue what I met: YouTube video (Just for more information, Vectors of output console is the speed and right part is my player.)
Thanks for your help.

Godot version Latest version exists on steam
in Engine by (12 points)

Please log in or register to answer this question.

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.