SWOP is a 2D platformer where you complete puzzles by swapping between the two characters. The non active character is frozen and will not be affected by physics in any way. Both characters also see a different world as well, for example if one character sees a platform the other will not see the platform.
Features:
Example code to swap between worlds.
using UnityEngine; using System.Collections; public class LevelManager : MonoBehaviour { //-------------- //TWO DIFFERENT level areas //-------------- enum ActiveAvatar { AVATAR1 = 1, AVATAR2 = 2 } //Keep track of both avatars private GameObject _levelAvatar1; private GameObject _levelAvatar2; private AvatarManager _avatarManager; //Initialize values on start void Start() { _avatarManager = GameManager.SingleTon().GetAvatarManager(); } //Update void Update() { if (Input.GetKeyDown(KeyCode.R)) { GameManager.SingleTon().GetLevelSelectManager().ReloadCurrentLevel(); } } //Make all children of a given object visible void EnableLevel(GameObject levelObjects) { Component[] renderers; renderers = levelObjects.GetComponentsInChildren<Renderer>(); foreach (Renderer renderer in renderers) { renderer.enabled = true; } Component[] colliders; colliders = levelObjects.GetComponentsInChildren<Collider>(); foreach (Collider collider in colliders) { collider.enabled = true; } Component[] rB; rB = levelObjects.GetComponentsInChildren<Rigidbody>(); foreach (Rigidbody body in rB) { body.isKinematic = false; body.useGravity = true; } Component[] lights; lights = levelObjects.GetComponentsInChildren<Light>(); foreach (Light light in lights) { light.enabled = true; } } //Make all children of a given object invisible void DisableLevel(GameObject levelObjects) { Component[] renderers; renderers = levelObjects.GetComponentsInChildren<Renderer>(); foreach (Renderer renderer in renderers) { renderer.enabled = false; } Component[] colliders; colliders = levelObjects.GetComponentsInChildren<Collider>(); foreach (Collider collider in colliders) { collider.enabled = false; } Component[] rB; rB = levelObjects.GetComponentsInChildren<Rigidbody>(); foreach (Rigidbody body in rB) { body.isKinematic = true; body.useGravity = false; } Component[] lights; lights = levelObjects.GetComponentsInChildren<Light>(); foreach (Light light in lights) { light.enabled = false; } } //Initialize the avatars public void SetLevelAvatars(GameObject level1, GameObject level2) { _levelAvatar1 = level1; _levelAvatar2 = level2; } //Swap the level according to the active avatar public void ChangeActiveLevel() { if ((ActiveAvatar)_avatarManager.GetActiveAvatar() == ActiveAvatar.AVATAR1) { EnableLevel(_levelAvatar1); DisableLevel(_levelAvatar2); } if ((ActiveAvatar)_avatarManager.GetActiveAvatar() == ActiveAvatar.AVATAR2) { EnableLevel(_levelAvatar2); DisableLevel(_levelAvatar1); } } }