Commit 8c6730c4 authored by Zsanet Sueli's avatar Zsanet Sueli
Browse files

Tsunami mode: added the switcher between the left and right controller

parent 917c1f32
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -3452,7 +3452,7 @@
            "id": "9ac024aa-bb93-4b4f-b974-0af0ab33892e",
            "actions": [
                {
                    "name": "MinimapControllerAction_LeftHand",
                    "name": "Switcher_ControllerAction_LeftHand",
                    "type": "Button",
                    "id": "069d07ca-dabd-47a4-93c1-1cdfea5e053c",
                    "expectedControlType": "",
@@ -3461,7 +3461,7 @@
                    "initialStateCheck": false
                },
                {
                    "name": "MinimapControllerAction_RightHand",
                    "name": "Switcher_ControllerAction_RightHand",
                    "type": "Button",
                    "id": "bda095b0-146c-4a75-a324-01b87d74fff8",
                    "expectedControlType": "",
@@ -3478,7 +3478,7 @@
                    "interactions": "Press",
                    "processors": "",
                    "groups": "",
                    "action": "MinimapControllerAction_LeftHand",
                    "action": "Switcher_ControllerAction_LeftHand",
                    "isComposite": false,
                    "isPartOfComposite": false
                },
@@ -3489,7 +3489,7 @@
                    "interactions": "Press",
                    "processors": "",
                    "groups": "",
                    "action": "MinimapControllerAction_RightHand",
                    "action": "Switcher_ControllerAction_RightHand",
                    "isComposite": false,
                    "isPartOfComposite": false
                }
+37 −17
Original line number Diff line number Diff line
@@ -653,6 +653,7 @@ GameObject:
  serializedVersion: 6
  m_Component:
  - component: {fileID: 435620007}
  - component: {fileID: 435620008}
  m_Layer: 0
  m_Name: TeleportMode_Controllers
  m_TagString: Untagged
@@ -677,6 +678,22 @@ Transform:
  - {fileID: 1572022421}
  m_Father: {fileID: 804414144}
  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &435620008
MonoBehaviour:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 435620006}
  m_Enabled: 1
  m_EditorHideFlags: 0
  m_Script: {fileID: 11500000, guid: 89ad068b554121a44899f22e7100abad, type: 3}
  m_Name: 
  m_EditorClassIdentifier: Assembly-CSharp::ActiveHandController
  leftHand: {fileID: -3835811510999428239, guid: c348712bda248c246b8c49b3db54643f,
    type: 3}
  rightHand: {fileID: 8406838762494054339, guid: c348712bda248c246b8c49b3db54643f,
    type: 3}
--- !u!1 &448700305
GameObject:
  m_ObjectHideFlags: 0
@@ -13606,6 +13623,7 @@ GameObject:
  m_Component:
  - component: {fileID: 1021102586}
  - component: {fileID: 1021102587}
  - component: {fileID: 1021102588}
  m_Layer: 0
  m_Name: Tsunami_Controller
  m_TagString: Untagged
@@ -13648,10 +13666,28 @@ MonoBehaviour:
  ballRed: {fileID: 0}
  ballBlue: {fileID: 0}
  greenBall: {fileID: 0}
  teleportAction: {fileID: 3279264004350380116, guid: c348712bda248c246b8c49b3db54643f,
  teleportActionLeft: {fileID: -6395602842196007441, guid: c348712bda248c246b8c49b3db54643f,
    type: 3}
  teleportActionRight: {fileID: 3279264004350380116, guid: c348712bda248c246b8c49b3db54643f,
    type: 3}
  steps: 15000
  stepSize: 0.1
--- !u!114 &1021102588
MonoBehaviour:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 1021102585}
  m_Enabled: 1
  m_EditorHideFlags: 0
  m_Script: {fileID: 11500000, guid: cf35af05e6f5c44488f349e48c191c96, type: 3}
  m_Name: 
  m_EditorClassIdentifier: Assembly-CSharp::TsunamiHandBinder
  activeHandController: {fileID: 435620008}
  teleport: {fileID: 1021102587}
  leftController: {fileID: 1332011437}
  rightController: {fileID: 1192504418}
--- !u!1 &1094841177
GameObject:
  m_ObjectHideFlags: 0
@@ -14616,7 +14652,6 @@ GameObject:
  m_Component:
  - component: {fileID: 1572022421}
  - component: {fileID: 1572022422}
  - component: {fileID: 1572022423}
  - component: {fileID: 1572022424}
  m_Layer: 0
  m_Name: Minimap_Controller
@@ -14665,21 +14700,6 @@ MonoBehaviour:
  cursorPrefab: {fileID: -8679921383154817045, guid: a913d2860f493a7468426e8324353cb2,
    type: 3}
  beamRenderer: {fileID: 1680986859}
--- !u!114 &1572022423
MonoBehaviour:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 1572022420}
  m_Enabled: 0
  m_EditorHideFlags: 0
  m_Script: {fileID: 11500000, guid: 672164733dc84244994b930294e9abf4, type: 3}
  m_Name: 
  m_EditorClassIdentifier: Assembly-CSharp::MiniMapController
  miniMapObject: {fileID: 1204040839}
  enableMenuAction: {fileID: 8406838762494054339, guid: c348712bda248c246b8c49b3db54643f,
    type: 3}
--- !u!114 &1572022424
MonoBehaviour:
  m_ObjectHideFlags: 0
+51 −0
Original line number Diff line number Diff line
using System;
using UnityEngine;
using UnityEngine.InputSystem;

public class ActiveHandController : MonoBehaviour
{


    // Switches between left or right controller 

    public enum Hand
    {
        Left,
        Right,
        None
    }

    public Hand CurrentHand { get; private set; } = Hand.None;

    [Header("Input")]
    public InputActionReference leftHand;
    public InputActionReference rightHand;

    public event Action<Hand> OnHandChanged;

    private void OnEnable()
    {

        leftHand.action.performed += _ => SetHand(Hand.Left);
        rightHand.action.performed += _ => SetHand(Hand.Right);


        leftHand.action.Enable();
        rightHand.action.Enable();
    }

    private void OnDisable()
    {
        leftHand.action.Disable();
        rightHand.action.Disable();
    }

    private void SetHand(Hand hand)
    {
        if (CurrentHand == hand) return;

        CurrentHand = hand;
        OnHandChanged?.Invoke(hand); //calls all the methods, that entered the event
    }
}
+2 −0
Original line number Diff line number Diff line
fileFormatVersion: 2
guid: 89ad068b554121a44899f22e7100abad
 No newline at end of file
+19 −6
Original line number Diff line number Diff line
@@ -11,7 +11,10 @@ public class MapTeleportToCurvedArea : MonoBehaviour
    public LineRenderer beamRenderer;
    public Transform cursorPrefab;
    public GameObject ballRed, ballBlue, greenBall;
    public InputActionReference teleportAction;

    [Header("Input Actions left and right to teleport")]
    public InputActionReference teleportActionLeft;
    public InputActionReference teleportActionRight;

    [Header("Ray Marching Settings")]
    public int steps = 10000;           // Number of steps
@@ -50,8 +53,11 @@ public class MapTeleportToCurvedArea : MonoBehaviour
    private void OnEnable()
    {

        teleportAction.action.Enable();
        teleportAction.action.performed += OnTeleportPerformed;
        teleportActionLeft.action.Enable();
        teleportActionLeft.action.performed += OnTeleportPerformed;

        teleportActionRight.action.Enable();
        teleportActionRight.action.performed += OnTeleportPerformed;

    }

@@ -59,8 +65,11 @@ public class MapTeleportToCurvedArea : MonoBehaviour
    private void OnDisable()
    {

        teleportAction.action.performed -= OnTeleportPerformed;
        teleportAction.action.Disable();
        teleportActionLeft.action.performed -= OnTeleportPerformed;
        teleportActionLeft.action.Disable();

        teleportActionRight.action.performed -= OnTeleportPerformed;
        teleportActionRight.action.Disable();
    }


@@ -132,6 +141,10 @@ public class MapTeleportToCurvedArea : MonoBehaviour

    public void OnTeleportPerformed(InputAction.CallbackContext context)
    {

        if (controller == null)
            return;

        Ray ray = new Ray(controller.position, controller.forward);

        if (TryGetCurvedHit_RayMarch(ray, out Vector3 hit))
Loading