Godot Version
Question
So, there is this small error that i can’t seem to get around, it’s always the same message i get.
Please help me, I’m still pretty new to developing games so I don’t really know what to do.
So, there is this small error that i can’t seem to get around, it’s always the same message i get.
Please help me, I’m still pretty new to developing games so I don’t really know what to do.
So the reddit infection of extremely low effort “photo of the screen” type of posts reached the forum too.
Is there a way to flag posts like these?
Hi there! It might be more helpful if you posted the code in the code quote-y brackets (Forget the name) instead of just as a screenshot. That way, if someone is able to help you debug, they can copy your code themself, without having to keep looking at your screenshot.
also, could you please provide more information about what the error is doing, and what it says* and what you’ve done already to work on it?
*I don’t speak the language that it looks like your error message is in. Maybe you could translate it to English, or if you’re not comfortable with english enough to do so, include in your original post contents of your english message in the same language you have the error message in. That way people who speak either of those 2 languages can help you, instead of having to be at least a little bit bilingual to help.
Sorry if this sounds strange, it will just make it easier for people to try to help you.
The error says:
Missing connected function '_on_grenade' for signal 'grenade' from node 'Level/player' to node 'Level/player'.
@newtodevelopment Do you connect some signals to functions that don’t exist in your code?
Sure, i will provide more pictures and context later when i am home again, thank you. I will update you on the error in english, more code (in form of text), and what i tried already.
I will look at that later, thank you
Sorry for the inconvenience, my picture quality of my phone really is not the best anymore
So, the error says:
Missing connected function ‘_on_grenade’ for signal ‘grenade’ from node ‘Level/player’ to node ‘Level/player’.
Every time i run the game, it gives me one debug error:
player.gd:25 @ _process(): Error calling from signal ‘laser’ to callable: ‘CharacterBody2D(player.gd)::_on_laser’: Method not found.
I don’t know what exactly that means, but it doesn’t seem to impact the game at all. It simply works the same as it should.
I initially tried to make a function using _on_laser() but it kept on giving me errors for every frame. Now i just get one every time i shoot a laser or a grenade.
I hope this can help you with figuring out what is wrong, since i have no idea either.
Please help me
I looked through the code but i don’t see any signals comnected to functions that do not exist, I’m full on lost on this part.
Hi, sorry if this is bothering you. But could you please post the whole script: I don’t see much signal code at the moment (though its early so maybe I missed it). But it looks likes (from the screenshot) that we are only seeing 20 lines of your 40 ish lines of code.
Also, is there another scene or script this code interacts with?
I realize this is a lot of questions, but the more information people have the better they can help you.
Yes, sorry i think i kinda misunderstood it from the first message.
I will post the whole code for both of the scripts that are related.
The first one will be from the player.gd, the second one from the level.gd.
Player.gd:
extends CharacterBody2D
signal laser(pos, direction)
signal grenade(pos, direction)
var can_laser : bool = true
var can_grenade : bool = true
func _process(_delta):
var direction = Input.get_vector("left", "right", "up", "down")
velocity = direction * 500
move_and_slide()
#rotate
look_at(get_global_mouse_position())
var player_direction = (get_global_mouse_position() - position).normalized()
if Input.is_action_pressed("primary action") and can_laser:
var laser_markers = $LaserStartPositions.get_children()
var selected_laser = laser_markers[randi() % laser_markers.size()]
can_laser = false
$LaserTimer.start()
laser.emit(selected_laser.global_position, player_direction)
if Input.is_action_pressed("secondary option") and can_grenade:
can_grenade = false
$GrenadeReloadTimer.start()
var pos = $LaserStartPositions.get_children()[0].global_position
grenade.emit(pos, player_direction)
func _on_timer_timeout():
can_laser = true
func _on_timer_2_timeout():
can_grenade = true
And now the level.gd script:
extends Node2D
var laser_scene: PackedScene = preload(“res://scenes/projectiles/laser.tscn”)
var grenade_scene: PackedScene = preload(“res://scenes/projectiles/grenade.tscn”)
func _on_gate_player_entered_gate(body):
print(“player has entered gate”)
print(body)
func _on_player_laser(pos, direction):
var laser = laser_scene.instantiate() as Area2D
laser.position = pos
laser.rotation_degrees = rad_to_deg(direction.angle()) + 90
laser.direction = direction
$Projectiles.add_child(laser)
func _on_player_grenade(pos, direction):
var grenade = grenade_scene.instantiate() as RigidBody2D
grenade.position = pos
grenade.linear_velocity = direction * grenade.speed
$Projectiles.add_child(grenade)
I hope this is what you meant, sorry for the many inconveiences caused.
Thank you so much for helping me bro.
thank you for posting the whole code.
I looked at the signals for godot 4.2 (as your post is tagged under godot-4) to better understand. I’m technically still on godot 3.5, so I needed a little information on how/ if it changed.
(If you want to look yourself, here is the link: Using signals — Godot Engine (stable) documentation in English )
It looks like you are emitting your signals with the correct number of arguments, which is good. The only thing I cannot tell (because it can be set up in godot OR in code) is if you’ve connected the signals.
If you’ve already set up the signals through the editor, I’m not quite sure what is causing your bug. If you have NOT set them up in the editor, you can either do so now, or connect them through code.
It’s entirely possible its a different problem: the main reason I was asking all the questions was to get information so that if I can’t help you hopefully someone else can. But at the moment i would check that the signals are connected. (You said earlier you checked that they were not connected to functions that don’t exist: did you check they connected properly to the functions that DO exist).
anyway. Thank you for providing the relevant information.
They should be connected properly, I followed a guide on it and weirdly enough, i did it correctly with another one before. When i look at the player scene, there are _on_laser() and _on _granade() in yellow even though they are connected as seen in the code and the function.This is just giving me a headache.
I will just leave it in the game and see if it fixes itself through future code updates. I won’t publish it, it’s just for me to learn the engine… would have been nice to know though. Anyway, I am really grateful for the effort you put in trying to help me, I really appreciate it.
Hope you have a nice day
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.