How would you get two separate sketches to interact?

Theoretically, how would you get two separate sketches to work together on the same website.

For example, I am looking at having two sketches, one in 2d processing as a control system and the second in 3d processing as a sketch getting controlled.

How would I get them to share information, variables, etc and would latency be too much of an issue?

Many thanks

1 Like

By control system do you mean some kinda GUI? :thinking:


2 Likes

Yeah, something along those lines.

I can’t see from your code how the two sketches work together (as it looks like just one sketch file)

I might be missing something, I’m still a beginner

Indeed it’s 1 sketch using a GUI library. I wanted to know 1st if such setup’d be enough for you. :woozy_face:

But if you really wanna have 1 p5js sketch controlling another 1, you can create a global object w/ some properties as a way for both sketches to communicate w/ each other. :bulb:

However, only 1 of those sketches can use the global mode approach. :globe_with_meridians:
The other 1 needs to use the instance mode approach: :warning:

Unless you put the other sketch inside an <iframe>: :framed_picture:

But doing so makes it much trickier for them to communicate. :calling:

1 Like