mirror of
https://github.com/ConjureETS/MTI860_VR_Multi_Controller.git
synced 2026-03-23 20:11:15 +00:00
Ajout Changement de mouvmeent
This commit is contained in:
parent
880d031867
commit
3306c30d10
@ -38,7 +38,7 @@ RenderSettings:
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 705507994}
|
||||
m_IndirectSpecularColor: {r: 0.44657826, g: 0.49641263, b: 0.57481676, a: 1}
|
||||
m_IndirectSpecularColor: {r: 0.18028334, g: 0.2257134, b: 0.30692226, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
@ -8953,12 +8953,11 @@ MonoBehaviour:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1941989041}
|
||||
m_Enabled: 1
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a3db9d02d190fcb46a9646c275a560e4, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
isDebug: 0
|
||||
body: {fileID: 1941989043}
|
||||
constSpeed: 2
|
||||
constRotation: 150
|
||||
@ -8999,6 +8998,74 @@ CapsuleCollider:
|
||||
m_Height: 1.4958494
|
||||
m_Direction: 1
|
||||
m_Center: {x: 0, y: 0.69886935, z: 0}
|
||||
--- !u!114 &1941989046
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1941989041}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d6c86531c866cd5409820556c3fc2c4e, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
selectedMovement: 0
|
||||
--- !u!114 &1941989047
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1941989041}
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 21b58e0dd1248034c871465fc721b43c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
body: {fileID: 1941989043}
|
||||
--- !u!114 &1941989048
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1941989041}
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 32e5e814edc24cf41999243fa65b4488, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
body: {fileID: 1941989043}
|
||||
--- !u!114 &1941989049
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1941989041}
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 1c56a27abb4b87b419b7fa61804fd6f8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
body: {fileID: 1941989043}
|
||||
--- !u!114 &1941989050
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1941989041}
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e5d6c19446783f148a1933e20dd05b52, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
body: {fileID: 1941989043}
|
||||
constSpeed: 2
|
||||
constRotation: 150
|
||||
constUpForce: 5
|
||||
--- !u!65 &1946133526
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -6,9 +6,6 @@ namespace JoyCon
|
||||
|
||||
public class JoyConMovement : JoyConBehaviour
|
||||
{
|
||||
[Header("DEBUG movement")]
|
||||
public bool isDebug;
|
||||
|
||||
[Header("References")]
|
||||
[SerializeField] private Rigidbody body;
|
||||
|
||||
@ -26,65 +23,32 @@ namespace JoyCon
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
if(!isDebug)
|
||||
{
|
||||
base.Start();
|
||||
_gyroMagnitude = new HistoricalData(5);
|
||||
_speed = 0;
|
||||
}
|
||||
base.Start();
|
||||
_gyroMagnitude = new HistoricalData(5);
|
||||
_speed = 0;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if(!isDebug)
|
||||
{
|
||||
Joycon j = JoyConManager.GetJoycon(JcLegInd);
|
||||
_playerDirection = j.GetButton(Joycon.Button.SHOULDER_2) ? Vector3.back : Vector3.forward;
|
||||
}
|
||||
Joycon j = JoyConManager.GetJoycon(JcLegInd);
|
||||
_playerDirection = j.GetButton(Joycon.Button.SHOULDER_2) ? Vector3.back : Vector3.forward;
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if(!isDebug)
|
||||
{
|
||||
Joycon j = JoyConManager.GetJoycon(JcLegInd);
|
||||
Joycon jArm = JoyConManager.GetJoycon(JcArmInd);
|
||||
Joycon j = JoyConManager.GetJoycon(JcLegInd);
|
||||
Joycon jArm = JoyConManager.GetJoycon(JcArmInd);
|
||||
|
||||
_gyroMagnitude.AddData(j.GetGyro().magnitude);
|
||||
_gyroMagnitude.AddData(j.GetGyro().magnitude);
|
||||
|
||||
_speed = IsWalking() ? 4 : 0;
|
||||
_speed = IsWalking() ? 4 : 0;
|
||||
|
||||
body.transform.Rotate(0, jArm.GetStick()[0] * constRotation * Time.fixedDeltaTime, 0);
|
||||
body.transform.Rotate(0, jArm.GetStick()[0] * constRotation * Time.fixedDeltaTime, 0);
|
||||
|
||||
body.AddRelativeForce(_playerDirection * (_speed * _gyroMagnitude.Total * constSpeed));
|
||||
body.AddForce(Vector3.up * constUpForce);
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
movement_wasd();
|
||||
#endif
|
||||
body.AddRelativeForce(_playerDirection * (_speed * _gyroMagnitude.Total * constSpeed));
|
||||
body.AddForce(Vector3.up * constUpForce);
|
||||
}
|
||||
|
||||
public bool IsWalking() => Mathf.Abs(_gyroMagnitude.Total) > 1;
|
||||
|
||||
|
||||
private void movement_wasd()
|
||||
{
|
||||
float moveHorizontal = Input.GetAxis("Horizontal");
|
||||
float moveVertical = Input.GetAxis("Vertical");
|
||||
transform.Rotate(0.0f, moveHorizontal * constSpeed * 2, 0.0f);
|
||||
transform.Translate(0, 0, moveVertical * constSpeed / 20);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public enum ChoiceOfMovement
|
||||
{
|
||||
wasd = 1,
|
||||
teleport = 2,
|
||||
joystick = 3,
|
||||
joycon = 4,
|
||||
omni = 5
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,31 +4,44 @@ using UnityEngine;
|
||||
|
||||
public class MovementGen : MonoBehaviour
|
||||
{
|
||||
private Dictionary<ChoiceOfMovement, MonoBehaviour> components;
|
||||
private ChoiceOfMovement currentMovement;
|
||||
|
||||
[Header("DEBUG movement")]
|
||||
public bool isDebug;
|
||||
[SerializeField] private ChoiceOfMovement selectedMovement;
|
||||
|
||||
[Header("References")]
|
||||
[SerializeField] private Rigidbody body;
|
||||
|
||||
[Header("Configuration")]
|
||||
[SerializeField] private int constSpeed;
|
||||
[SerializeField] private int constRotation;
|
||||
[SerializeField] private int constUpForce;
|
||||
|
||||
private int _speed;
|
||||
|
||||
private Vector3 _gyroMagnitude;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
components = new Dictionary<ChoiceOfMovement, MonoBehaviour>();
|
||||
components.Add(ChoiceOfMovement.wasd, this.GetComponent<WasdMovement>());
|
||||
components.Add(ChoiceOfMovement.teleport, this.GetComponent<TeleportMovement>());
|
||||
components.Add(ChoiceOfMovement.joystick, this.GetComponent<JoystickMovement>());
|
||||
components.Add(ChoiceOfMovement.joycon, this.GetComponent<JoyCon.JoyConMovement>());
|
||||
components.Add(ChoiceOfMovement.omni, this.GetComponent<OmniMovement>());
|
||||
|
||||
selectedMovement = ChoiceOfMovement.wasd;
|
||||
currentMovement = ChoiceOfMovement.wasd;
|
||||
components[currentMovement].enabled = true;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
void FixedUpdate()
|
||||
{
|
||||
|
||||
if(selectedMovement != currentMovement)
|
||||
{
|
||||
components[currentMovement].enabled = false;
|
||||
components[selectedMovement].enabled = true;
|
||||
currentMovement = selectedMovement;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ChoiceOfMovement
|
||||
{
|
||||
wasd = 0,
|
||||
teleport = 1,
|
||||
joystick = 2,
|
||||
joycon = 3,
|
||||
omni = 4
|
||||
}
|
||||
}
|
||||
|
||||
8
Assets/Scripts/Movements.meta
Normal file
8
Assets/Scripts/Movements.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a86f3b2619818bc448825ebf9786c092
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
21
Assets/Scripts/Movements/JoystickMovement.cs
Normal file
21
Assets/Scripts/Movements/JoystickMovement.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class JoystickMovement : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField] private Rigidbody body;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Movements/JoystickMovement.cs.meta
Normal file
11
Assets/Scripts/Movements/JoystickMovement.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c56a27abb4b87b419b7fa61804fd6f8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
21
Assets/Scripts/Movements/OmniMovement.cs
Normal file
21
Assets/Scripts/Movements/OmniMovement.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class OmniMovement : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField] private Rigidbody body;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Movements/OmniMovement.cs.meta
Normal file
11
Assets/Scripts/Movements/OmniMovement.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 32e5e814edc24cf41999243fa65b4488
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
21
Assets/Scripts/Movements/TeleportMovement.cs
Normal file
21
Assets/Scripts/Movements/TeleportMovement.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class TeleportMovement : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField] private Rigidbody body;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Movements/TeleportMovement.cs.meta
Normal file
11
Assets/Scripts/Movements/TeleportMovement.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 21b58e0dd1248034c871465fc721b43c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
29
Assets/Scripts/Movements/WasdMovement.cs
Normal file
29
Assets/Scripts/Movements/WasdMovement.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class WasdMovement : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField] private Rigidbody body;
|
||||
|
||||
[Header("Configuration")]
|
||||
[SerializeField] private int constSpeed;
|
||||
[SerializeField] private int constRotation;
|
||||
[SerializeField] private int constUpForce;
|
||||
|
||||
// Start is called before the first frame update
|
||||
private void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
private void FixedUpdate()
|
||||
{
|
||||
float moveHorizontal = Input.GetAxis("Horizontal");
|
||||
float moveVertical = Input.GetAxis("Vertical");
|
||||
transform.Rotate(0.0f, moveHorizontal * constSpeed * 2, 0.0f);
|
||||
transform.Translate(0, 0, moveVertical * constSpeed / 20);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Movements/WasdMovement.cs.meta
Normal file
11
Assets/Scripts/Movements/WasdMovement.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5d6c19446783f148a1933e20dd05b52
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
x
Reference in New Issue
Block a user