0 votes

enter image description here

Hello guys, I want the player to be moved inside and outside based on keypress. The problem is as the player can be at any angle any time , I'm not able to understand how to move him to some distance inside/outisde.

with the help of this article https://kidscancode.org/godot_recipes/2d/2d_align_surface/

I have did this

snap = transform.y * 128 if !is_jumping else Vector2.ZERO
velocity.y += GRAVITY * delta + force
velocity.x += 1
velocity = velocity.normalized() * SPEED
velocity = move_and_slide_with_snap(velocity.rotated(rotation),snap,-transform.y,true,4,PI/3,false)
velocity = velocity.rotated(-rotation)

please help

in Engine by (14 points)

1 Answer

0 votes

I have an idea to fake it. You could use two sprites to represent the player. When the key is pressed, you could hide one sprite and show another one. Using this method, the player position could be consistent. You don't need to change the player's position according to the platform. However, you may need to rotate the player to fit it.

by (315 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.