mirror of
https://github.com/ConjureETS/MTI860_VR_Multi_Controller.git
synced 2026-03-24 04:21:15 +00:00
Modification to Movement Scripts : added interface and made Teleportation work. See BugList.txt for the list of bugs that I found.
This commit is contained in:
parent
751e4abf3b
commit
4b6d4fda91
@ -1,10 +1,11 @@
|
||||
using UnityEngine;
|
||||
using Assets.Scripts.Movements;
|
||||
using UnityEngine;
|
||||
|
||||
namespace JoyCon
|
||||
{
|
||||
// Blame Jimmy
|
||||
|
||||
public class JoyConMovement : JoyConBehaviour
|
||||
public class JoyConMovement : JoyConBehaviour, IScriptDeMovement
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField] private Rigidbody body;
|
||||
@ -50,5 +51,9 @@ namespace JoyCon
|
||||
}
|
||||
|
||||
public bool IsWalking() => Mathf.Abs(_gyroMagnitude.Total) > 1;
|
||||
public void BeforeDisable()
|
||||
{
|
||||
// TODO throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Assets.Scripts.Movements;
|
||||
using UnityEngine;
|
||||
|
||||
public class MovementGen : MonoBehaviour
|
||||
@ -30,12 +31,23 @@ public class MovementGen : MonoBehaviour
|
||||
{
|
||||
if(selectedMovement != currentMovement)
|
||||
{
|
||||
if (components[currentMovement] is IScriptDeMovement)
|
||||
{
|
||||
|
||||
((IScriptDeMovement) components[currentMovement]).BeforeDisable();
|
||||
}
|
||||
|
||||
components[currentMovement].enabled = false;
|
||||
components[selectedMovement].enabled = true;
|
||||
currentMovement = selectedMovement;
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeMovement(ChoiceOfMovement newChoice)
|
||||
{
|
||||
selectedMovement = newChoice;
|
||||
}
|
||||
|
||||
public enum ChoiceOfMovement
|
||||
{
|
||||
wasd = 0,
|
||||
|
||||
7
Assets/Scripts/Movements/IScriptDeMovement.cs
Normal file
7
Assets/Scripts/Movements/IScriptDeMovement.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace Assets.Scripts.Movements
|
||||
{
|
||||
public interface IScriptDeMovement
|
||||
{
|
||||
public void BeforeDisable();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Movements/IScriptDeMovement.cs.meta
Normal file
11
Assets/Scripts/Movements/IScriptDeMovement.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 381f097ec95f20743a0287e68f70a011
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,8 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Assets.Scripts.Movements;
|
||||
using UnityEngine;
|
||||
|
||||
public class JoystickMovement : MonoBehaviour
|
||||
// Useless, voir WASD movement
|
||||
public class JoystickMovement : MonoBehaviour, IScriptDeMovement
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField] private Rigidbody body;
|
||||
@ -18,4 +20,9 @@ public class JoystickMovement : MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void BeforeDisable()
|
||||
{
|
||||
// TODO throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Assets.Scripts.Movements;
|
||||
using UnityEngine;
|
||||
|
||||
public class OmniMovement : MonoBehaviour
|
||||
public class OmniMovement : MonoBehaviour, IScriptDeMovement
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField] private Rigidbody body;
|
||||
@ -18,4 +19,9 @@ public class OmniMovement : MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void BeforeDisable()
|
||||
{
|
||||
//TODO throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,21 +1,86 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Assets.Scripts.Movements;
|
||||
using UnityEngine;
|
||||
|
||||
public class TeleportMovement : MonoBehaviour
|
||||
public class TeleportMovement : MonoBehaviour, IScriptDeMovement
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField] private Rigidbody body;
|
||||
|
||||
private bool flag = true;
|
||||
private List<MonoBehaviour> scriptsList;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
flag = true;
|
||||
scriptsList = new List<MonoBehaviour>();
|
||||
GameObject teleportScript = GameObject.FindGameObjectsWithTag("TeleportationScriptsList").FirstOrDefault();
|
||||
if (teleportScript != null)
|
||||
{
|
||||
scriptsList.Add(teleportScript.GetComponent<LocomotionController>());
|
||||
scriptsList.Add(teleportScript.GetComponent<LocomotionTeleport>());
|
||||
scriptsList.Add(teleportScript.GetComponent<TeleportInputHandlerTouch>());
|
||||
scriptsList.Add(teleportScript.GetComponent<TeleportTargetHandlerPhysical>());
|
||||
scriptsList.Add(teleportScript.GetComponent<TeleportAimVisualLaser>());
|
||||
scriptsList.Add(teleportScript.GetComponent<TeleportAimHandlerParabolic>());
|
||||
scriptsList.Add(teleportScript.GetComponent<TeleportOrientationHandlerThumbstick>());
|
||||
scriptsList.Add(teleportScript.GetComponent<TeleportTransitionInstant>());
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Sheeeet, Cant find!");
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
if (scriptsList.Count == 0)
|
||||
{
|
||||
Debug.Log("SHEEEET");
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
foreach (var script in scriptsList)
|
||||
{
|
||||
script.enabled = true;
|
||||
}
|
||||
|
||||
flag = false;
|
||||
}
|
||||
|
||||
//changer à false si on désactive le script
|
||||
}
|
||||
|
||||
public void BeforeDisable()
|
||||
{
|
||||
if (scriptsList.Count != 0)
|
||||
{
|
||||
foreach (var script in scriptsList)
|
||||
{
|
||||
script.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
flag = true;
|
||||
}
|
||||
|
||||
/*
|
||||
public Transform teleportTarget;
|
||||
//public GameObject thePlayer;
|
||||
|
||||
void OnTriggerEnter(Collider other)
|
||||
{
|
||||
transform.position = teleportTarget.transform.position;
|
||||
//thePlayer.transform.position = teleportTarget.transform.position;
|
||||
}
|
||||
*/
|
||||
}
|
||||
@ -1,9 +1,15 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Assets.Scripts.Movements;
|
||||
using UnityEngine;
|
||||
|
||||
public class WasdMovement : MonoBehaviour
|
||||
public class WasdMovement : MonoBehaviour, IScriptDeMovement
|
||||
{
|
||||
/*
|
||||
Si version non-vr, utilise WASD.
|
||||
Si utilise la version VR, utilise les joysticks
|
||||
*/
|
||||
|
||||
[Header("References")]
|
||||
[SerializeField] private Rigidbody body;
|
||||
|
||||
@ -26,4 +32,9 @@ public class WasdMovement : MonoBehaviour
|
||||
transform.Rotate(0.0f, moveHorizontal * constSpeed * 2, 0.0f);
|
||||
transform.Translate(0, 0, moveVertical * constSpeed / 20);
|
||||
}
|
||||
|
||||
public void BeforeDisable()
|
||||
{
|
||||
//TODO throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
1
BugList.txt
Normal file
1
BugList.txt
Normal file
@ -0,0 +1 @@
|
||||
Bug WASDmovement avec controllers : quand tourne + avance au max, Character est propulser
|
||||
Loading…
x
Reference in New Issue
Block a user