#Signal connection on parallel scenes

1 messages · Page 1 of 1 (latest)

dapper dawn
#

Signal connection on parallel scenes

#

@rapid ember @rancid anchor

#

here

rapid ember
#

I thank you

dapper dawn
#

so this

#

explain

#

lol

rapid ember
#

that's where signal goes

#

there also should be arrow from fountain to hud

dapper dawn
#

what are you using the signal for?

rapid ember
#

hahahaha

#

that's quite broad topic

dapper dawn
#

just a quick explanation lol

#

so that i get a bit of context

rapid ember
#

but more or less 5yo explanation is: I change state, then cursor changes to sprite, sprite must reach area2d of fountain, fountain emits "materials" it has, on area exit it doesn't, or rather emits nothing

#

sounds like utter bullshit but I'll make it exist first with thoughts and prayers

rancid anchor
#

How did this break with a global signal?

rapid ember
#

I added it to global and then had ape cymbals gif

rancid anchor
rapid ember
rancid anchor
#

Can I have a looksee at the script?

dapper dawn
#

indeed, would help lol

rapid ember
#

because I never connected anything before with just code

rancid anchor
#

Does it include things you'd like to pass with the signal?

rapid ember
#

so don't have reflex on how to

dapper dawn
#

i know how to do this with C# events, but i kinda forgor how to do this in GDS lol

rapid ember
dapper dawn
#

but as an example in C# you'd connect your event on _ready(), to the function you wanna run when it gets emitted

rancid anchor
dapper dawn
#

like line 51 (for parameters) or line 52 (functions without params)

#

(ignore everything else in the image lol)

#

i assume a similar principle is used with Godot Signals

rapid ember
#

so function without parents

#

nods

#

would you also happen to know how to make a collection of unique elements?

dapper dawn
#

as in an array of a class? (like an array of class_name player for example)

#

or a dictionary?

rapid ember
#

just something that only takes in unique values, or at le

#

wait

#

you're genius thanks

#

I can just track quantity of material and subtract if it goes away

#

instead of fucking
readding and reremoving it back and forth

#

how did I not think of that 🤦‍♂️

#

you're wonderful person

dapper dawn
#

lol

rancid anchor
#

Context is important.

dapper dawn
#

explaining something you're working on sometimes helps you solve the problem yourself

rapid ember
# rancid anchor Context is important.

see, if you hover over 2 fountains, you get two water material, and if done wrong, you can get in a limbo where you either have all water or none, which is bollocks

dapper dawn
rapid ember
#

it flashed only now

#

and before you nobody was too willing to listen anyway

dapper dawn
#

get a reference to the autoload node with the global signal script and connect to the signals

dapper dawn
rapid ember
#

way more than you think actually

#

so...

#

is there a caveat on disconnecting signals from stuff that's gone?

dapper dawn
#

i don't think so

#

in a modern engine like Godot it should just clean it up for you if you delete a node with an event (signal) that isn't disconnected

rapid ember
#

but how to connect signal to newborns then

dapper dawn
#

newborns? lol

#

you mean nodes that are instanced (created) at runtime (while the game is running)?

dapper dawn
#

on their _ready() function

#

which is called when they're instanced and ready to be used

rapid ember
#

nay

#

you connect from global script which always exists no?

#

but things that change are ones you connect to

#

how would you "request" global to connect to you on your ready gdthinkowo

dapper dawn
#

no, you don't have global connect to your node

#

you have your node connect to global

#

you'd define the signal you wanna connect to in the global script

rapid ember
#

how

#

global doesn't have functions to connect to

rancid anchor
#

You don't connect from the global

#

just define signals there

rapid ember
rancid anchor
#

In your other scripts, like area or player, you'd connect them.

rapid ember
rancid anchor
#

Which part?

rapid ember
#

connect where from/to

rancid anchor
#

Say we have a global "damage" function.

GlobalSignal.gd (autoload)

signal damaged(Hurt: CharacterBody3D, Source : CharacterBody3D, DamageTaken : float)

Player.gd

func _ready():
  GlobalSignal.damaged.connect(_on_damaged)

func _on_damaged(Hurt: CharacterBody3D, Source : CharacterBody3D, DamageTaken : float):
  pass
#

So the signal is sent out to all nodes, you just need to tell them to listen for the signal.

rapid ember
#

ah, so you connect from self to self

#

kekus...

rancid anchor
#

Sending the signal is as easy as GlobalSignals.damaged.emit()

(don't forget to pass variables needed)

rapid ember
#

yeah I thankfully know how to send, as I mentioned it was working alright

#

just never been connecting via code

rancid anchor
#

Also no promises that the code functions as is I don't have access to Godot atm so syntax might be slightly off

#

But that's the general idea.

rapid ember
#

you've touched another hurtful topic though

#

classes

rancid anchor
#

What about em

rapid ember
#

I've been there, I've given my player class_name and called it a day, since I don't know what else I'm supposed to do with it

rancid anchor
#

I mean you don't have to do anything

rapid ember
#

how so

rancid anchor
#

Classes are useful when you want to define additional functions

rapid ember
#

which I do

rancid anchor
#

Like your player might have things that regular CharacterBodies don't have

rapid ember
#

wish I knew what they have to begin with...

rancid anchor
#

It's all in the documentation

#

So this is the general chain of inheritance

#

adding a class name to your script like:
class_name Player
extends CharacterBody3D

Just adds another chain in the link

dapper dawn
#

more of a C# example, but the concept would be the same for GDS

dapper dawn
#

go ahead

rapid ember
#

why not Unity at this point in your case

dapper dawn
#

lmao

#

well in my case i don't tend to use signals, i usually use C# events

#

but to answer your question...

#

1st: Godot is open-source, Unity is not

#

if Godot suddenly decided to ruin their engine, i could just yoink the source code and fork it

#

2nd: Godot has a much better user experience than Unity

rapid ember
dapper dawn
#

3rd: Unity is *Free™ (* free until you pass a certain treshold), Godot is just free

deep cosmos
dapper dawn
#

yea

#

not to mention you don't know what kind of spyware telemetry they potentially have packaged in there, with that whole "oh we will know if you meet our requirements to pay install fees" talk

#

with Godot that isn't an issue, you can pull apart the source code and analyse it yourself

#

not to mention yea, 4th: you can modify the engine code if you need to

#

i actually did this in a project, to add engine support for FFB

rancid anchor
#

Not to mention follow along with development when you have engine issues gdpray

dapper dawn
rapid ember
#

hmmm but Unity has better uh encryption?

dapper dawn
#

what, of the game files?

#

you can also do that in Godot

rapid ember
#

as well as it's possible to extract that key with reversing like ghidra

dapper dawn
#

maybe, i'm not a security expert

#

but sure, let's assume so, why should i care as an indie dev lol?

#

my projects are small singleplayer games, they don't exactly need top notch asset security

rapid ember
#

yada

#

wait what were we talking about

#

I wanted to make a game

#

then something happened and we ended up with this encryption talk, as if someone needs to encrypt something right now

dapper dawn
dapper dawn
dapper dawn
#

lol

rapid ember
#

why did I do that

#

ah, because harmony patches

rapid ember
#

I really need to get thoughts straight ||or gay||

dapper dawn
#

:3

#

lol

#

meanwhile i should go to bed

#

so bai bai

rapid ember
rapid ember
#

thanks for being of this much help

dapper dawn
dapper dawn
#

:3