Godot Version
version 4.7.1-stable
Question
I'm making a simple game, where you have a jar with a marble and you shake it the jar to make the ball move. You can take the lid on and off the jar. I added this drag and drop script for my jar:
extends Sprite2D
var of = Vector2(0,0)
# we use delta, remember process is the running program
func _process(delta):
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
global_position = get_global_mouse_position() - of
and the same drag and drop script for the lid as well:
extends Sprite2D
# set this to false
var of = Vector2(0,0)
# we use delta, remember process is the running program
func _process(delta):
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
global_position = get_global_mouse_position() - of
func _physics_process(delta: float) -> void:
# Add the gravity.
pass
#is called when an input is made
When I move the jar body around, the lid of the jar stick to it as well:
When you move the jar around, the lid would stay at the top of the jar, unless you remove the lid then it falls to the ground.
Any suggestions on how I can solve the issue?