0 votes

I have a basic script to move my character, if another object hits a body change a boolean variable that will run moveandslide() for the player. When the player hits an Area2D it will stop and this code will keep repeating.

func move_character():
if GLOBALS.playerGoingToMove == true: #If i hit the box I move
    self.get_parent().get_node("PLAYER/Body").move_and_slide(Vector2(50,0))
elif GLOBALS.playerGoingToMove == false:
     self.get_parent().get_node("PLAYER/Body").move_and_slide(Vector2(0,0))

movecharacter() is inside of _physicsprocess(delta)
Initially it will run slowly, wait for a bit then it will go fast, wait for a bit and it will go faster.

I think I know what's going on but I can't fix it. I believe the Vector2(50,0) keeps on increasing but if I set it to Vector2(0,0) I thought that it would fix it but it doesn't.
I saw a video where he made the Vector2 a variable and reset the variable to equal the new current vector but I can't do that because it will stop moving once it hits something rather than using input controls.

Would really like input for my code if I did something wrong or forgotten about something.

in Engine by (20 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.