I am brand new to coding so I have no idea what I'm doing, I'm using GODOT 2.1.
I am trying to create a button the player can press in the game using "ui_accept" by moving over to it with an animated sprite.
This is the script for my player
export var speed = 175
var vel = Vector2()
onready var sprite = get_node("Sprite")
var anim = "walkies"
screensize = get_viewport_rect().size
var input = Vector2(0,0)
input.x = Input.is_action_pressed("ui_right") - Input.is_action_pressed("ui_left")
vel = input * speed
set_pos(get_pos() + vel * delta)
if vel.x != 0:
anim = "walkies"
anim = "idle"
if vel.x > 0:
elif vel.x < 0:
var pos = get_pos() * vel * delta
I have a button scene that can detect when the player is within range with this code (albeit the player sprite walks "behind" the button which is not ideal I would like to appear in front of the button) :
var anim = "default"
var pos = Vector2(500,240)
func onArea2Dareaenter( area ):
How can I make it so that the player can walk into the button's range, press "uiaccept", and activate the animated sprite in the button scene? Eventually I'd like to have the button do something else but right now I just want to figure out how to get it to animate when the player is WITHIN range and then PRESSES the "uiaccept" key.