# TWA. Interactions in the Orangery Doc
**Where**: [[DESIGNS/ToyWorldsAtlas/Orangery_Doc|Orangery_Doc]]
**Related**: [[DESIGNS/ToyWorldsAtlas/TWA_VFX_Doc|TWA_VFX_Doc]]
**Requirement**: Atlas Prefab (with RigidBody2D)
## ToDo
- [ ] A&A -> Cicadas (sound)
- [-] E&E -> Submarine
- [ ] E&? -> Submarine's corpus material cycles lerps through colours
- [ ] H Atlas -> "magnifying glass" effect
- Use a separate rendering layer to make a SpriteMask (the "magnifying glass")
- Prefab = amoebaParent (2x smaller). SmallAmoeba is a bit bigger than. SSX is even bigger
*Refactoring*:
- [ ] Instead of GameObject.Find, make an EffectController.gameObject with public variables
## Concept
(1) Atlases of the same type interact between each other. Each type interacts with its type in a same way which is different from the interaction between two or more atlases of another same type. E.g., [[DESIGNS/ToyWorldsAtlas/A-Atlas_Doc|A]] & [[DESIGNS/ToyWorldsAtlas/A-Atlas_Doc|A]] interacts differently, from B & B.
(2) *Optional* Atlases of different types interact with each other differently. E.g., A & B interact in a different way than A & C, or B & C.
### Methodology
- Tags + Colliders
- Visual Effects or particle systems, or physics -- see [[DESIGNS/ToyWorldsAtlas/TWA_VFX_Doc]]
- When the player clicks on the atlas in the Orangery, they can control its movement and collide it with other atlases as they want
### Effects
- CD-ROM-ish glow ([article](https://www.alanzucconi.com/2017/07/15/cd-rom-shader-2/?utm_source=chatgpt.com))
- Ripple distortion effect ([tutorial](https://www.youtube.com/watch?v=ajbNS8mncRo) -- URP required)
- Shadow trail
- More sounds
- More orangery UI-related effects
- Dates on branches change to the future (e.g. 2077 or 2049) or historical dates
- Grass changes colour and text
- The flower gains additional petals of other colours, and they rotate together ([[DESIGNS/ToyWorldsAtlas/AtlasI_Doc|Radiolaria]]?)
- Background changes colour / texture
- Waves
- The atlas repeats itself, similar to shadow, but radial
- Or an implosive wave: contours containing smaller contours. They decrease inside the atlas, revealing it further
| Status | Participating<br>Atlases | Effect | Reference |
| :----- | :----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
| | A & A | Little beetles crawl sideways<br>or<br>Cicadas (sound) | |
| ✅ | B & B | RANGERY.text glows,<br>Leafes move | |
| ✅ | C & C | Stars firework particles | |
| ✅ | D & D | Water bubbles particle | [xOctoManx (YouTube)](https://www.youtube.com/watch?v=ajsA6vWBhKI) |
| ✅ | E & E | Submarine | |
| | > E & ? | Submarine's corpus material cycles & lerps through colours | |
| ✅ | F & F | Blinking eyes visual effect | |
| ✅ | G & G | Give phrases / profiles on interaction (speech bubbles or subtitles) | |
| | H & H | When H & H interact > they overlap > a magnified version of amoeba is seen through a sprite mask<br>- Sprite mask, two static giant amoebas | |
## Code
### C & C (for a template)
```cs
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class Interact_C : MonoBehaviour
{
// Particle effects prefabs
public GameObject sparkPrefab; // for Atlas C + Atlas C
private GameObject sparkPrefabInst;
private void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.tag == "C_Atlas") // C
{
Vector2 contactPoint = col.contacts[0].point;
GameObject sparkPrefabInst = Instantiate(sparkPrefab, contactPoint, Quaternion.identity);
sparkPrefabInst.name = "C_C_effect";
}
}
private void OnCollisionExit2D(Collision2D col)
{
if (col.gameObject.tag == "C_Atlas") // C
{
DestroyEffects("C_C_effect", 1f);
}
}
private void DestroyEffects(string effectName, float duration)
{
GameObject[] collisionEffects = FindObjectsOfType<GameObject>()
.Where(go => go.name == effectName)
.ToArray();
for (int i = 0; i < collisionEffects.Length; i++)
{
if (i == collisionEffects.Length - 1)
Destroy(collisionEffects[i], duration); // the last effect is destroyed with a delay
else
Destroy(collisionEffects[i]); // all effects before last are destroyed immediately
}
}
}
```
### PlayerAtlasController
**From** Atlas_InOrangery.cs (See [[DESIGNS/ToyWorldsAtlas/Orangery_Doc|Orangery_Doc]])
- OnMouseDown (Atlas's clicked) -> Add PlayerController.cs
- For all game objects in the scene -> if has PlayerController.cs -> delete PlCo.cs
- OnMouseDown (on another atlas) -> Add PlayerController.cs to another
```cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerAtlasController : MonoBehaviour
{
private Rigidbody2D atlRig;
private void Start()
{
atlRig = gameObject.GetComponent<Rigidbody2D>();
}
// PLAYER MOVES AVATAR
private void PlayerMovesAtlas()
{
if (Input.GetKeyDown(KeyCode.W))
{
atlRig.velocity = new Vector3(0, 5, 0);
}
if (Input.GetKeyUp(KeyCode.W))
{
atlRig.velocity = new Vector3(0, 0, 0);
}
if (Input.GetKeyDown(KeyCode.S))
{
atlRig.velocity = new Vector3(0, -5, 0);
}
if (Input.GetKeyUp(KeyCode.S))
{
atlRig.velocity = new Vector3(0, 0, 0);
}
if (Input.GetKeyDown(KeyCode.A))
{
atlRig.velocity = new Vector3(-5, 0, 0);
}
if (Input.GetKeyUp(KeyCode.A))
{
atlRig.velocity = new Vector3(0, 0, 0);
}
if (Input.GetKeyDown(KeyCode.D))
{
atlRig.velocity = new Vector3(5, 0, 0);
}
if (Input.GetKeyUp(KeyCode.D))
{
atlRig.velocity = new Vector3(0, 0, 0);
}
FixRotation();
}
private void FixRotation()
{
gameObject.GetComponent<Transform>().rotation = Quaternion.Euler(0, 0, 0);
}
private void Update()
{
PlayerMovesAtlas();
}
}
```
![[NEPOBJEDIVI/atlas.borders]]