Godot Version
Player Scene
extends CharacterBody2D
var point = 0
var rng = RandomNumberGenerator.new()
var direction_x := 0.0
var facing_right := true
@export var speed = 400
signal shoot(pos: Vector2, direction: bool)
signal dice_result1(pos: Vector2)
signal dice_result2(pos: Vector2)
signal self_Shot(pos: Vector2)
signal item_Grabbed()
signal spin()
var can_shoot := true
var can_roll := true
func _process(delta: float) → void:
#handles the players movement/gravity
get_input()
apply_gravity()
velocity.x = direction_x * speed
move_and_slide()
#get_facing_direction():
func _on_player_self(bullet_Type: Variant) → void:
print(“hello”)
#checking what type if being shot run the apporite one
if bullet_Type == 1:
speed = speed + 600
await get_tree().create_timer(30).timeout
speed = speed - 600
func get_input():
#sends the player in the chosen direction
direction_x = Input.get_axis(“ui_left”, “ui_right”)
if Input.is_action_just_pressed("dice") and can_roll:
#creating random number sending it to dice function
var dice_Num1 = rng.randi_range(1, 6)
var dice_Num2 = rng.randi_range(1, 6)
var dice_Num = dice_Num1 + dice_Num2
dice_Result(dice_Num1, dice_Num2)
can_roll = false
await get_tree().create_timer(30).timeout
can_roll = true
if Input.is_action_just_pressed("shoot") and can_shoot:
#telling what needs to that a bullet has been shot
shoot.emit(global_position)#, facing_right #sends out the signal and where the player is
can_shoot = false
#creating a pause to stop spam
await get_tree().create_timer(0.6).timeout
can_shoot = true
if Input.is_action_just_pressed("self") and can_shoot:
print("input if")
self_Shot.emit(global_position)#sends out the signal and where the player is
can_shoot = false
await get_tree().create_timer(0.6).timeout
can_shoot = true
if Input.is_action_just_pressed("jump") and is_on_floor():
#godots 2d graph is "upside down" meaning the ground is in the positive direction
velocity.y = -450
if Input.is_action_just_pressed("use"):
print("used")
item_Grabbed.emit()
items scene
extends Area2D
signal player_Range_in(in_Range: Variant)
signal add_type_1()
var in_Range = 0
func _on_body_entered(body: Node2D) → void:
print(“entered”)
add_type_1.emit()
in_Range = 1
func _on_body_exited(body: Node2D) → void:
print(“exited”)
in_Range = 0
func _on_item_Grabbed() → void:
if in_Range == 1:
print(“item used”)
add_type_1.emit()
Question
I’m new to godot and find signals confusing to me the syntax for for this singal should work but it doesn’t. help