Godot Version
v4.4.1.stable.mono.official [49a5bc7b6]
Question
I’m a beginner in Godot, and I’ve been trying to put together a point-and-click game with little animations. I wrote a script for picking up and placing objects (extends Sprite2D):
Summary
var dragging=false
var obj_offset=Vector2(0,0)
func _process(_delta):
if dragging:
position = get_global_mouse_position()-obj_offset
#without the -obj_offset the object will snap to the center of the mouse
#Leaf1
func _on_bl_1_button_down() → void:
dragging=true
obj_offset=get_global_mouse_position()-global_position
func _on_bl_1_button_up() → void:
dragging=false
#Leaf2
func _on_bl_2_button_down() → void:
dragging=true
obj_offset=get_global_mouse_position()-global_position
func _on_bl_2_button_up() → void:
dragging=false
#Leaf3
func _on_bl_3_button_down() → void:
dragging=true
obj_offset=get_global_mouse_position()-global_position
func _on_bl_3_button_up() → void:
dragging=false
#Leaf4
func _on_bl_4_button_down() → void:
dragging=true
obj_offset=get_global_mouse_position()-global_position
func _on_bl_4_button_up() → void:
dragging=false
And made a few looped animations that are meant to play in the scene:
Summary
extends AnimationPlayer
func _ready():
speed_scale = 0.412
play(“Leaf1Move”)
play(“Leaf2Move”)
play(“Leaf3Move”)
play(“Leaf4Move”)
The animations are preventing the script from working aka. picking up and putting down the objects. I attempted to pause()/stop(false) the animations in the AP’s script once the button (sprite) is clicked (via _on_button_pressed()) but neither works. Is there a way to make the button press/object pickup stop the animation? Or for the pickup script to work while the animation is playing?
Here’s a link to a video with my struggle → google drive LINK