This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

how to control the character with the button?

dzosekdzosek Posts: 37Member
edited March 2020 in 2D

I'd like to move my character left and right using the button

func right_press():
    velocity.x += 1
    velocity = velocity.normalized() * speed

func _physics_process(delta):
    velocity.y += antgravity * delta
    position.x = clamp(position.x, 20, screen_size.x)

but it doesn't work. The character flies to the right.


  • SIsilicon28SIsilicon28 Posts: 693Moderator
    edited March 2020

    Well no kidding! you're increasing velocity.x, but there's nowhere I see it being decreased.
    Also, what is calling right_press? The button?

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.