# How would you get two separate sketches to interact?

**URL:** <https://discourse.processing.org/t/how-would-you-get-two-separate-sketches-to-interact/12368>\
**Category:** Coding Questions\
**Created:** [June 29, 2019, 12:01am UTC](https://discourse.processing.org/t/how-would-you-get-two-separate-sketches-to-interact/12368 "2019-06-29T00:01:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![KeirMeDear](https://avatars.discourse-cdn.com/v4/letter/k/8c91f0/32.png) [@KeirMeDear](https://discourse.processing.org/u/KeirMeDear)\
**Post date:** [June 29, 2019, 12:01am UTC](https://discourse.processing.org/t/how-would-you-get-two-separate-sketches-to-interact/12368/1 "2019-06-29T00:01:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [June 29, 2019, 2:56am UTC](https://discourse.processing.org/t/how-would-you-get-two-separate-sketches-to-interact/12368/3 "2019-06-29T02:56:31Z")

</div>

> [@KeirMeDear](#):
>
> , one in 2d processing as a control system

By control system do you mean some kinda GUI? 🤔

> <https://gist.github.com/GoSubRoutine/861b48f0b0118219c6a7cdd28309ee62>

> <https://gist.github.com/GoSubRoutine/861b48f0b0118219c6a7cdd28309ee62>

---

<div class="post-metadata">

**Author:** ![KeirMeDear](https://avatars.discourse-cdn.com/v4/letter/k/8c91f0/32.png) [@KeirMeDear](https://discourse.processing.org/u/KeirMeDear)\
**Post date:** [June 30, 2019, 8:42pm UTC](https://discourse.processing.org/t/how-would-you-get-two-separate-sketches-to-interact/12368/4 "2019-06-30T20:42:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [June 30, 2019, 11:41pm UTC](https://discourse.processing.org/t/how-would-you-get-two-separate-sketches-to-interact/12368/5 "2019-06-30T23:41:32Z")

</div>

> [@KeirMeDear](#):
>
> (as it looks like just one sketch file)

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

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. 💡

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

- [Global and instance mode · processing/p5.js Wiki · GitHub](http://GitHub.com/processing/p5.js/wiki/Global-and-instance-mode)

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

- [\<iframe\>: The Inline Frame element - HTML: HyperText Markup Language | MDN](http://Developer.Mozilla.org/en-US/docs/Web/HTML/Element/iframe)

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