Locomotion stuff
- Holding the primary button on both controllers for 1 second will enable/disable locomotion - Swapped joysticks' functions
This commit is contained in:
parent
e7c92fa6bf
commit
e0b09a5ea4
BIN
Assets/Resources/Audio/loco off.mp3
Normal file
BIN
Assets/Resources/Audio/loco off.mp3
Normal file
Binary file not shown.
22
Assets/Resources/Audio/loco off.mp3.meta
Normal file
22
Assets/Resources/Audio/loco off.mp3.meta
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 15a013a0c90197f4aacd50e80e006409
|
||||||
|
AudioImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 6
|
||||||
|
defaultSettings:
|
||||||
|
loadType: 0
|
||||||
|
sampleRateSetting: 0
|
||||||
|
sampleRateOverride: 44100
|
||||||
|
compressionFormat: 1
|
||||||
|
quality: 1
|
||||||
|
conversionMode: 0
|
||||||
|
platformSettingOverrides: {}
|
||||||
|
forceToMono: 0
|
||||||
|
normalize: 1
|
||||||
|
preloadAudioData: 1
|
||||||
|
loadInBackground: 0
|
||||||
|
ambisonic: 0
|
||||||
|
3D: 1
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
Assets/Resources/Audio/loco on.mp3
Normal file
BIN
Assets/Resources/Audio/loco on.mp3
Normal file
Binary file not shown.
22
Assets/Resources/Audio/loco on.mp3.meta
Normal file
22
Assets/Resources/Audio/loco on.mp3.meta
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1b1e3bea19569c145b0fb1d2c4758914
|
||||||
|
AudioImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 6
|
||||||
|
defaultSettings:
|
||||||
|
loadType: 0
|
||||||
|
sampleRateSetting: 0
|
||||||
|
sampleRateOverride: 44100
|
||||||
|
compressionFormat: 1
|
||||||
|
quality: 1
|
||||||
|
conversionMode: 0
|
||||||
|
platformSettingOverrides: {}
|
||||||
|
forceToMono: 0
|
||||||
|
normalize: 1
|
||||||
|
preloadAudioData: 1
|
||||||
|
loadInBackground: 0
|
||||||
|
ambisonic: 0
|
||||||
|
3D: 1
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
21
Assets/Script/LocomotionStatus.cs
Normal file
21
Assets/Script/LocomotionStatus.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class LocomotionStatus : MonoBehaviour
|
||||||
|
{
|
||||||
|
private TextMeshPro text;
|
||||||
|
|
||||||
|
// Start is called before the first frame update
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
text = GetComponent<TextMeshPro>();
|
||||||
|
UpdateText(LocomotionToggle.IsEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateText(bool status)
|
||||||
|
{
|
||||||
|
text.text = "LOCOMOTION: " + (status ? "ENABLED" : "DISABLED");
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Script/LocomotionStatus.cs.meta
Normal file
11
Assets/Script/LocomotionStatus.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 351fc1d968d436d44b431f42a0570812
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
86
Assets/Script/LocomotionToggle.cs
Normal file
86
Assets/Script/LocomotionToggle.cs
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Events;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
|
||||||
|
[RequireComponent(typeof(AudioSource))]
|
||||||
|
public class LocomotionToggle : MonoBehaviour
|
||||||
|
{
|
||||||
|
[System.Serializable]
|
||||||
|
public class LocomotionToggleEvent : UnityEvent<bool> { }
|
||||||
|
|
||||||
|
public static bool IsEnabled
|
||||||
|
{
|
||||||
|
get { return _state; }
|
||||||
|
}
|
||||||
|
private static bool _state = true;
|
||||||
|
|
||||||
|
private float timer = 0;
|
||||||
|
private bool actionDone = false;
|
||||||
|
|
||||||
|
private bool leftHeld = false;
|
||||||
|
private bool rightHeld = false;
|
||||||
|
|
||||||
|
public LocomotionToggleEvent locoEvent;
|
||||||
|
|
||||||
|
private AudioClip soundOn;
|
||||||
|
private AudioClip soundOff;
|
||||||
|
private AudioSource audioSrc;
|
||||||
|
|
||||||
|
[Header("Settings")]
|
||||||
|
[SerializeField]
|
||||||
|
private float holdTime;
|
||||||
|
|
||||||
|
[Header("References")]
|
||||||
|
[SerializeField]
|
||||||
|
private GameObject locomotionController;
|
||||||
|
[SerializeField]
|
||||||
|
private InputActionProperty leftHandAction;
|
||||||
|
[SerializeField]
|
||||||
|
private InputActionProperty rightHandAction;
|
||||||
|
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
if (locoEvent == null)
|
||||||
|
locoEvent = new LocomotionToggleEvent();
|
||||||
|
|
||||||
|
audioSrc = GetComponent<AudioSource>();
|
||||||
|
audioSrc.playOnAwake = false;
|
||||||
|
soundOn = Resources.Load<AudioClip>("Audio/loco on");
|
||||||
|
soundOff = Resources.Load<AudioClip>("Audio/loco off");
|
||||||
|
|
||||||
|
leftHandAction.action.started +=
|
||||||
|
(InputAction.CallbackContext _) => leftHeld = true;
|
||||||
|
leftHandAction.action.canceled +=
|
||||||
|
(InputAction.CallbackContext _) => leftHeld = false;
|
||||||
|
rightHandAction.action.started +=
|
||||||
|
(InputAction.CallbackContext _) => rightHeld = true;
|
||||||
|
rightHandAction.action.canceled +=
|
||||||
|
(InputAction.CallbackContext _) => rightHeld = false;
|
||||||
|
|
||||||
|
locomotionController.SetActive(_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
if (leftHeld && rightHeld)
|
||||||
|
{
|
||||||
|
timer += Time.unscaledDeltaTime;
|
||||||
|
if (timer >= holdTime && !actionDone)
|
||||||
|
{
|
||||||
|
_state = !_state;
|
||||||
|
locoEvent.Invoke(_state);
|
||||||
|
locomotionController.SetActive(_state);
|
||||||
|
actionDone = true;
|
||||||
|
|
||||||
|
audioSrc.clip = _state ? soundOn : soundOff;
|
||||||
|
audioSrc.Play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
timer = 0;
|
||||||
|
actionDone = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
Assets/Script/LocomotionToggle.cs.meta
Normal file
11
Assets/Script/LocomotionToggle.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e28739818e0aced4fbf1afd49f82dcff
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -45,9 +45,9 @@ public class PanelButton : MonoBehaviour
|
|||||||
private void OnTriggerEnter(Collider other)
|
private void OnTriggerEnter(Collider other)
|
||||||
{
|
{
|
||||||
_insideColliderCount += 1;
|
_insideColliderCount += 1;
|
||||||
|
ButtonPress();
|
||||||
if (doesBeep)
|
if (doesBeep)
|
||||||
audioSrc.Play();
|
audioSrc.Play();
|
||||||
ButtonPress();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTriggerExit(Collider other)
|
private void OnTriggerExit(Collider other)
|
||||||
|
@ -35,7 +35,7 @@ public class PanelLocker : MonoBehaviour
|
|||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
statusImg.texture = unlockImg;
|
statusImg.texture = isLocked ? lockImg : unlockImg;
|
||||||
audioSrc.clip = lockSound;
|
audioSrc.clip = lockSound;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,19 +61,18 @@ public class PanelLocker : MonoBehaviour
|
|||||||
if (ratio >= 1 && !actionTaken)
|
if (ratio >= 1 && !actionTaken)
|
||||||
{
|
{
|
||||||
isLocked = !isLocked;
|
isLocked = !isLocked;
|
||||||
|
|
||||||
audioSrc.clip = isLocked ? lockSound : unlockSound;
|
|
||||||
audioSrc.Play();
|
|
||||||
|
|
||||||
timerRing.color = Color.cyan;
|
|
||||||
statusImg.texture = isLocked ? lockImg : unlockImg;
|
|
||||||
|
|
||||||
foreach (var btn in panelButtons)
|
foreach (var btn in panelButtons)
|
||||||
{
|
{
|
||||||
btn.SetActive(!isLocked);
|
btn.SetActive(!isLocked);
|
||||||
}
|
}
|
||||||
|
|
||||||
actionTaken = true;
|
actionTaken = true;
|
||||||
|
|
||||||
|
timerRing.color = Color.cyan;
|
||||||
|
statusImg.texture = isLocked ? lockImg : unlockImg;
|
||||||
|
|
||||||
|
audioSrc.clip = isLocked ? lockSound : unlockSound;
|
||||||
|
audioSrc.Play();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
8
Assets/StreamingAssets.meta
Normal file
8
Assets/StreamingAssets.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b7d4e5e75e98f8e4384a0a48e42b93b1
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
File diff suppressed because one or more lines are too long
1654
Assets/XR Input Actions.inputactions
Normal file
1654
Assets/XR Input Actions.inputactions
Normal file
File diff suppressed because it is too large
Load Diff
14
Assets/XR Input Actions.inputactions.meta
Normal file
14
Assets/XR Input Actions.inputactions.meta
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0f61ebe746c23ef42b8010bd8ac1e3ab
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 8404be70184654265930450def6a9037, type: 3}
|
||||||
|
generateWrapperCode: 0
|
||||||
|
wrapperCodePath:
|
||||||
|
wrapperClassName:
|
||||||
|
wrapperCodeNamespace:
|
Loading…
Reference in New Issue
Block a user