Godot Version
4.1.1
Question
Here is the code:
extends CollisionShape2D
@export var transformation = Transform2D()
@export var rotation_speed = 1000
@onready var pickcollision
var limb
var rotating = false # Degrees per step
var total_rotation = 0 # Total rotation so far
@onready var beardy = $"../../../CollisionPolygon2D"
@onready var picksprite = $"../AnimatedSprite2D3"
var tilemap
var small_movement = Vector2(0.1, 0.1)
# Called when the node enters the scene tree for the first time.
func _ready():
limb = $"."
limb.visible = false
# Load the scene containing the TileMap
var scene = load("res://Scenes/Themine.tscn")
# Instance the scene to access its nodes
var scene_instance = scene.instantiate()
# Find the TileMap node within the scene
tilemap = find_tilemap_node(scene_instance)
pickcollision = $"."
emit_signal("pickcollision_ready")
pickcollision.set_deferred("disabled", true)
func _process(delta):
limb = $".."
pickcollision = $"."
transformation.origin = pickcollision.global_position
##var collide
# Check for key press
if Input.is_action_pressed("ui_accept"):
CollisionManagement
# Check for key release
else:
rotating = false
pickcollision.set_deferred("disabled", true)
limb.visible = true
pickcollision.rotation = 0
func rotate_limb(delta):
if rotating:
# Rotate the limb
limb.rotate(deg_to_rad(rotation_speed) * delta)
# Update total rotation
total_rotation += rotation_speed
# Check if total rotation reaches 360 degrees
if total_rotation >= 360:
total_rotation = 0
rotating = false
func find_tilemap_node(node):
# Recursive function to find the TileMap node within the scene
if node is TileMap:
return node
Here is the errors:
E 0:00:02:0405 PickaxeSwing.gd:11 @ _ready(): Node not found: "../../../CollisionPolygon2D" (relative to "/root/PickaxeSwing").
<C++ Error> Method/function failed. Returning: nullptr
<C++ Source> scene/main/node.cpp:1620 @ get_node()
<Stack Trace> PickaxeSwing.gd:11 @ _ready()
and
E 0:00:02:0454 PickaxeSwing.gd:29 @ _ready(): Can't emit non-existing signal "pickcollision_ready".
<C++ Error> Condition "!signal_is_valid && !script.is_null() && !Ref<Script>(script)->has_script_signal(p_name)" is true. Returning: ERR_UNAVAILABLE
<C++ Source> core/object/object.cpp:1026 @ emit_signalp()
<Stack Trace> PickaxeSwing.gd:29 @ _ready()
Thanks for your help, as always.