Sharing a function?

Hi all

I’ve been looking around at various game engines and like the look of flowlab.

Just wanted to ask if there is a way for multiple characters to share one or more functions instead of having to copy the same logic for each character?

Thanks

TimCS

2 Likes

Yup it’s called a parent.

2 Likes

Thanks for the quick reply is this under the sprite settings or behaviour methods ?

Is there an example I can look at ?

Thanks

TimCS

1 Like

Np, it should be under where you name the object and it should say parent above it.

3 Likes

Thanks can this method allow for the behaviours to be random?

For example these characters will do random tasks during the level however these tasks are to be shared across these characters.

Like moving from a to b

b to c

And so on and each character will do a different task from the same code pot

Is this possible? Are there any examples of this?

Thanks

TimCS

1 Like

You can acheive this with routers. Just set it to Randomize Next Route, connect a Once to the “select” and “in” inputs, and put the different tasks to different outs from the router.
Example:
image

The Router block can be found in Logic & Math if you scroll down
@ me if you need more help

1 Like

Wow ok looking better by the minute!

I do have other questions but I’ll post them in a new topic so not to get things messy here.

I suppose the parent object that holds these behaviours can be left off screen and just serve that purpose?

Kind Regards,

TimCS

2 Likes

yep, as simple as that. then all children of the parent will share the code. :+1:

1 Like

The parent object doesnt have to be in the game. All code it the parent object should run in the child object.

2 Likes