Signal doesn't work
Asked Answered
C

18

0

Hi, so i want to emit a signal when the axe has touched the tree 3 times. I get the error: @ _ready(): In Object of type 'CharacterBody2D': Attempt to connect nonexistent signal 'CollisionsWithTree3' to callable 'Area2D(Baum.gd)::collwithtree3'.



Corneliuscornell answered 9/2 at 17:2 Comment(0)
A
0

Corneliuscornell

You need to remove that () from your signal name. You need parenthesis on your signals only when you want to send parameters with it. And if you do so, you have to put some variables and optional a type for those inside the parenthesis.

No parameters:
signal health_depleted

With parameters:
signal health_changed(old_value, new_value)

Taken from:
https://docs.godotengine.org/en/stable/getting_started/step_by_step/signals.html

Auriol answered 9/2 at 18:18 Comment(0)
C
0

Auriol I tried it but it still doesn't work

Corneliuscornell answered 9/2 at 18:38 Comment(0)
A
0

From where is _on_axe_tree_collision() called?
Does it print "sde"?

Auriol answered 9/2 at 18:45 Comment(0)
C
0

Auriol Yea it prints sde. Thats the rest of my code (pls don't mind the bad movement script XD):

Corneliuscornell answered 9/2 at 18:49 Comment(0)
A
0

Are you using Godot3?

Auriol answered 9/2 at 18:54 Comment(0)
C
0

Auriol no godot 4.2.1

Corneliuscornell answered 9/2 at 18:55 Comment(0)
A
0

Sorry, I'm somewhat lost right now. Especially about the signal connections. Can you maybe upload your project somewhere so I can test it?
However, I'm going for a walk now ^^

Auriol answered 9/2 at 19:12 Comment(0)
C
0

Auriol I have it on github is your name the same as here? I should maybe also go for a walk for once xD

Corneliuscornell answered 9/2 at 19:35 Comment(0)
A
0

I was lazy, short walk. 😃

That's me: https://github.com/TAGames However I'm not really familiar with github.

Auriol answered 9/2 at 19:59 Comment(0)
C
0

Auriol I invited you

Corneliuscornell answered 9/2 at 20:4 Comment(0)
A
0

Got it. Can't open some scenes, because baumchara.gd is missing. Now I'm figuring out how to remove those dependicies.

Auriol answered 9/2 at 20:14 Comment(0)
C
0

Auriol i removed them i don't know why they are still there

Corneliuscornell answered 9/2 at 20:17 Comment(0)
A
0

Ok, I just create some empty script for baumchara.gd and now I can look at it.

Hmm, I think you general node structure is pretty messed up.
Are the trees supposed to be moved?

EDIT: Or could you tell me what you are trying to achieve?

Auriol answered 9/2 at 20:20 Comment(0)
C
0

Auriol no the tree can just stand there

Corneliuscornell answered 9/2 at 20:22 Comment(0)
A
0

Ok and you want a player that can move and chop trees and switch weapons/tools?

Auriol answered 9/2 at 20:23 Comment(0)
C
0

Auriol you can already do it by clicking f/r and I'm trying to make it so you can cut them down but the signal doesn't work somehow

Corneliuscornell answered 9/2 at 20:25 Comment(0)
A
0

Give me an hour or so ^^ Then I can explain/show some things.

Auriol answered 9/2 at 20:42 Comment(0)
C
0

Auriol thanks bro^^

Corneliuscornell answered 9/2 at 20:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.