0 votes

** I cannot move the character from A to B in the path as shown in the image, it directly slides from A to B instead. what changes should I made if the image should follow the same path as shown in the image.Below is the code I have written,Please correct my code**

extends AnimatedSprite

var Charspeed = 1
var At
A = false
var AtB = false
var At
C = false

onready var p = get_parent()

func _ready():
pass # Replace with function body.

func _process(delta):

if not At_A and position.x < p.get_node("Point A").position.x:
    position.x += Char_speed

if not At_B and position.y < p.get_node("Point B").position.y:
    position.y += Char_speed

if not At_C and position.x < p.get_node("Point C").position.x:
    position.x += Char_speed

See the Image for better Understanding

in Engine by (15 points)
edited by

There is no image, and the code snippet doesn't help understanding your question. Could you provide some more details, please?

Hi Srinivas,

are you just trying to animate the character along that path without any player control? Like a movie?

If yes, maybe you can simplify things by using a Path2D - that is Godot's built in mechanism for following paths. Docs are here

There is a nice recipe here which shows you how to make it work

(By the way, I love the look of the graphics)

Thanks a lot for responding immediately.

1 Answer

+1 vote
Best answer

You can use

if Input.is _ action _ pressed("the move button "):
velocity.x = +speed

works fine with me

remove the spaces between the underscores btw

by (54 points)
selected by
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.