Script calling the signal /
‘’’
extends CharacterBody2D
class_name Player
var go = “2”
const SPEED = 250.0
const CLIMB_SPEED = -150.0
const JUMP_VELOCITY = -600.0
var STOP = 0
var facing = 0
var GOSTOP
@onready var character_body_2d: Player = $“.”
@onready var collision_shape_2d: CollisionShape2D = $CollisionShape2D
@onready var sprite_2d: AnimatedSprite2D = $Sprite2D
@onready var spikes: Area2D = $“../Spike Folder/Spikes”
func _physics_process(delta: float) → void:
if is_on_floor():
STOP = 0
spikes.connect(“Go1”, gok)
if Input.is_action_just_pressed("Space") and is_on_floor():
velocity.y = JUMP_VELOCITY
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction := Input.get_axis("A", "D")
if direction:
if STOP == 0 and velocity.x < SPEED + 1 and velocity.x > -SPEED -1:
velocity.x = direction * SPEED
if velocity.x > SPEED and is_on_floor():
velocity.x = move_toward(velocity.x, SPEED, 20)
if STOP > 0:
STOP = STOP - 1
if facing == "r":
velocity.x = 250
if facing == "l":
velocity.x = -250
if STOP < 0:
STOP = 0
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
#Climbing
if is_on_wall() and Input.is_action_pressed("E"):
velocity.x = 0
if Input.is_action_pressed("W"):
velocity.y = CLIMB_SPEED
elif Input.is_action_pressed("S"):
velocity.y = -CLIMB_SPEED
else:
velocity.y = 0
if Input.is_action_pressed("D") and Input.is_action_pressed("Space") and sprite_2d.flip_h == true:
velocity.x = SPEED * direction
velocity.y = JUMP_VELOCITY
if Input.is_action_pressed("A") and Input.is_action_pressed("Space") and sprite_2d.flip_h == false:
velocity.x = SPEED * direction
velocity.y = JUMP_VELOCITY
elif is_on_wall() and Input.is_action_just_pressed("Space") and not is_on_floor():
if sprite_2d.flip_h == true:
velocity.x = 250
velocity.y = JUMP_VELOCITY
STOP = 18
facing="r"
elif sprite_2d.flip_h == false:
velocity.x = -250
velocity.y = JUMP_VELOCITY
STOP = 18
facing = "l"
elif not is_on_floor() and not is_on_wall():
velocity += get_gravity() * delta
elif is_on_wall_only():
if velocity.y > 0:
velocity += (get_gravity() * delta)/2
else:
velocity += get_gravity() * delta
#Animations
if velocity.x < 0:
sprite_2d.flip_h = true
if velocity.x > 0:
sprite_2d.flip_h = false
if velocity.y < 0 and not is_on_floor():
sprite_2d.play("Jumping")
elif velocity.y > 0 and not is_on_floor():
sprite_2d.play("Falling")
elif velocity.x != 0 and is_on_floor and not is_on_wall():
sprite_2d.play("Running")
else:
sprite_2d.play("Default")
if go == "go":
GOSTOP = 24
if GOSTOP != 0:
velocity.x = 0
velocity.y = 0
sprite_2d.play("Death")
GOSTOP = GOSTOP - 1
else:
GOSTOP = 24
character_body_2d.position.x = 1217
character_body_2d.position.y = -447
sprite_2d.play("Respawn")
if GOSTOP != 0:
velocity.x = 0
velocity.y = 0
GOSTOP = GOSTOP - 1
go = "fa"
move_and_slide()
func gok():
print(“hi”)
go = “go”
‘’’
Script defining the signal /
‘’’
extends Area2D
@onready var character_body_2d: Player = $“../../CharacterBody2D”
@onready var guy: AnimatedSprite2D = $“res://Main Character.tscn.CharacterBody2D.Sprite2D”
signal Go1
var playery
var playerx
var RLSTOP =0
var GO =“0”
func _on_body_entered(body: Node) → void:
if body is Player:
playerx = character_body_2d.position.x/1152
playerx = ceil(playerx)
playery = character_body_2d.position.y/648
playery = ceil(playery)
if playerx == 2 and playery == 0:
emit_signal(“Go1”)
if playerx == 2 and playery == -1:
character_body_2d.position.x = 1594
character_body_2d.position.y = -703
if playerx == 1 and playery == -1:
character_body_2d.position.x = 1136
character_body_2d.position.y = -1117
if playerx == 1 and playery == -2:
character_body_2d.position.x = 427
character_body_2d.position.y = -1351
if playerx == 1 and playery == -3:
character_body_2d.position.x = 575
character_body_2d.position.y = -2014
‘’’
Question
Why is this not working? This is the exact error
main_character.gd:20 @ _physics_process(): In Object of type ‘Area2D’: Attempt to connect nonexistent signal ‘Go1’ to callable ‘CharacterBody2D(Player)::gok’.