Rig first stage refector
This commit is contained in:
parent
71098561e2
commit
53c6027e7c
6 changed files with 143 additions and 98 deletions
|
@ -1864,7 +1864,6 @@ GameObject:
|
|||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 416451006}
|
||||
- component: {fileID: 416451007}
|
||||
m_Layer: 0
|
||||
m_Name: Rig
|
||||
m_TagString: Untagged
|
||||
|
@ -1889,39 +1888,6 @@ Transform:
|
|||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &416451007
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 416451005}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 85a9e91f5490eb7459a500d8f39024fa, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
mono: {fileID: 0}
|
||||
design: {fileID: 11400000, guid: e32077fc3027a1b48909bb54527a2ad4, type: 2}
|
||||
main: {fileID: 1796811812}
|
||||
disconnected: {fileID: 1638248270}
|
||||
head: {fileID: 963194228}
|
||||
con: {fileID: 45752347}
|
||||
lCon: {fileID: 588278528}
|
||||
hangingRod: {fileID: 1554483892}
|
||||
recordCam: {fileID: 850212509}
|
||||
ovrCon: 0
|
||||
controllerRot: {x: 0, y: 0, z: 0, w: 1}
|
||||
inputRot: {x: 0, y: 0, z: 0, w: 1}
|
||||
controllerPos: {x: 0, y: 0, z: 0}
|
||||
joystick: {x: 0, y: 0, z: 0}
|
||||
boxShake: {x: 0, y: 0, z: 0}
|
||||
boxOffset: {x: 0, y: 0, z: 0}
|
||||
alignRecordCam: 1
|
||||
lerper:
|
||||
t: 0
|
||||
spring: 60
|
||||
dampen: 30
|
||||
--- !u!1 &434999704
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -7751,7 +7717,31 @@ MonoBehaviour:
|
|||
DRM: 1
|
||||
design: {fileID: 11400000, guid: e32077fc3027a1b48909bb54527a2ad4, type: 2}
|
||||
metro: {fileID: 408032442}
|
||||
rig: {fileID: 416451007}
|
||||
rig:
|
||||
mono: {fileID: 0}
|
||||
scale: 0
|
||||
headOffset: {x: 0, y: 0, z: 0}
|
||||
pivotPos: {x: 0, y: 0, z: 0}
|
||||
design: {fileID: 0}
|
||||
main: {fileID: 0}
|
||||
disconnected: {fileID: 0}
|
||||
rig: {fileID: 0}
|
||||
head: {fileID: 0}
|
||||
con: {fileID: 0}
|
||||
lCon: {fileID: 0}
|
||||
hangingRod: {fileID: 0}
|
||||
recordCam: {fileID: 0}
|
||||
ovrCon: 0
|
||||
controllerRot: {x: 0, y: 0, z: 0, w: 1}
|
||||
inputRot: {x: 0, y: 0, z: 0, w: 1}
|
||||
controllerPos: {x: 0, y: 0, z: 0}
|
||||
boxShake: {x: 0, y: 0, z: 0}
|
||||
boxOffset: {x: 0, y: 0, z: 0}
|
||||
alignRecordCam: 0
|
||||
lerper:
|
||||
t: 0
|
||||
spring: 1
|
||||
dampen: 1
|
||||
boxUI: {fileID: 1510915029}
|
||||
tongueLine: {fileID: 1821719419}
|
||||
graphXData: {fileID: 11400000, guid: a2a60279d0f57e841b54091e749bdccb, type: 2}
|
||||
|
@ -7839,6 +7829,31 @@ MonoBehaviour:
|
|||
m_EditorClassIdentifier:
|
||||
logic:
|
||||
mono: {fileID: 0}
|
||||
rig:
|
||||
mono: {fileID: 0}
|
||||
scale: 60
|
||||
headOffset: {x: 0, y: 0, z: -22}
|
||||
pivotPos: {x: 0, y: 2.8, z: 0}
|
||||
design: {fileID: 0}
|
||||
main: {fileID: 0}
|
||||
disconnected: {fileID: 1638248270}
|
||||
rig: {fileID: 416451006}
|
||||
head: {fileID: 963194228}
|
||||
con: {fileID: 45752347}
|
||||
lCon: {fileID: 588278528}
|
||||
hangingRod: {fileID: 1554483892}
|
||||
recordCam: {fileID: 850212509}
|
||||
ovrCon: 0
|
||||
controllerRot: {x: 0, y: 0, z: 0, w: 1}
|
||||
inputRot: {x: 0, y: 0, z: 0, w: 1}
|
||||
controllerPos: {x: 0, y: 0, z: 0}
|
||||
boxShake: {x: 0, y: 0, z: 0}
|
||||
boxOffset: {x: 0, y: 0, z: 0}
|
||||
alignRecordCam: 1
|
||||
lerper:
|
||||
t: 0
|
||||
spring: 60
|
||||
dampen: 30
|
||||
render:
|
||||
mono: {fileID: 0}
|
||||
test: 20
|
||||
|
|
|
@ -7,7 +7,7 @@ public class Logic
|
|||
[HideInInspector]
|
||||
public Monolith mono;
|
||||
|
||||
// public Rig rig;
|
||||
public Rig rig;
|
||||
|
||||
// [Header("Variables")]
|
||||
|
||||
|
@ -15,12 +15,12 @@ public class Logic
|
|||
|
||||
public void Set(InspectorSetter setter)
|
||||
{
|
||||
|
||||
rig.Set(setter);
|
||||
}
|
||||
|
||||
public void Fetch(InspectorSetter setter)
|
||||
{
|
||||
|
||||
rig.Fetch(setter);
|
||||
}
|
||||
|
||||
public void Start(Monolith mono)
|
||||
|
|
|
@ -6,7 +6,7 @@ public class Monolith : MonoBehaviour
|
|||
public Logic logic;
|
||||
public Render render;
|
||||
|
||||
[Header("Variables")]
|
||||
[Header("Design")]
|
||||
public float test;
|
||||
public string words = "";
|
||||
public Vector3 v3;
|
||||
|
|
|
@ -3,46 +3,61 @@ using UnityEngine;
|
|||
using UnityEngine.XR;
|
||||
|
||||
[Serializable]
|
||||
public class Rig : MonoBehaviour
|
||||
public class Rig
|
||||
{
|
||||
[HideInInspector]
|
||||
public Monolith mono;
|
||||
|
||||
[Header("Design")]
|
||||
public float scale;
|
||||
public Vector3 headOffset, pivotPos;
|
||||
|
||||
public void Set(InspectorSetter setter)
|
||||
{
|
||||
setter.Set("Rig.scale", scale);
|
||||
setter.Set("Rig.headOffset", headOffset);
|
||||
setter.Set("Rig.pivotPos", pivotPos);
|
||||
}
|
||||
|
||||
public void Fetch(InspectorSetter setter)
|
||||
{
|
||||
headOffset = setter.Fetch("Rig.scale", scale);
|
||||
headOffset = setter.Fetch("Rig.headOffset", headOffset);
|
||||
pivotPos = setter.Fetch("Rig.pivotPos", pivotPos);
|
||||
}
|
||||
|
||||
[Header("References")]
|
||||
public Design design;
|
||||
public Main main;
|
||||
public GameObject disconnected;
|
||||
public Transform head, con, lCon, hangingRod;
|
||||
public Transform rig, head, con, lCon, hangingRod;
|
||||
public Camera recordCam;
|
||||
|
||||
[Header("Variables")]
|
||||
public OVRInput.Controller ovrCon;
|
||||
|
||||
[HideInInspector]
|
||||
public Quaternion controllerRot = Quaternion.identity;
|
||||
[HideInInspector]
|
||||
public Quaternion inputRot = Quaternion.identity;
|
||||
public Vector3 controllerPos, joystick;
|
||||
[HideInInspector]
|
||||
public Vector3 controllerPos;
|
||||
|
||||
bool leftOn, rightOn, touchOn;
|
||||
Vector3 headOffset;
|
||||
public Vector3 boxShake, boxOffset;
|
||||
|
||||
public bool alignRecordCam;
|
||||
|
||||
void Start()
|
||||
public void Start()
|
||||
{
|
||||
Game.OnBump += Bump;
|
||||
Game.OnCrash += Bump;
|
||||
|
||||
// headOffset.y = 32f;
|
||||
headOffset.y = design.headOffset.y;
|
||||
headOffset.z = design.headOffset.z;
|
||||
|
||||
recordCam.gameObject.SetActive(Application.isEditor);
|
||||
}
|
||||
|
||||
Quaternion flipRot = Quaternion.identity;
|
||||
float flipEuler = 180;
|
||||
public Lerper lerper;
|
||||
void Update()
|
||||
public void Update()
|
||||
{
|
||||
// Input System
|
||||
UnityEngine.XR.XRDevice.DisableAutoXRCameraTracking(Camera.main, true);
|
||||
|
@ -80,7 +95,7 @@ public class Rig : MonoBehaviour
|
|||
flipEuler *= -1;
|
||||
lerper.t *= -1;
|
||||
}
|
||||
transform.localScale = Vector3.one * design.scale;
|
||||
rig.localScale = Vector3.one * scale;
|
||||
Quaternion targetRot = Quaternion.Euler(0, flipEuler, 0);
|
||||
if (OVRInput.Get(OVRInput.Button.PrimaryHandTrigger, ovrCon))
|
||||
{
|
||||
|
@ -91,17 +106,18 @@ public class Rig : MonoBehaviour
|
|||
lerper.Update(0);
|
||||
}
|
||||
flipRot = Quaternion.SlerpUnclamped(Quaternion.identity, targetRot, lerper.t);
|
||||
transform.rotation = flipRot;
|
||||
transform.position = flipRot * -head.localPosition * design.scale;
|
||||
transform.position += design.pivotPos + (head.rotation * headOffset);
|
||||
rig.rotation = flipRot;
|
||||
rig.position = flipRot * -head.localPosition * scale;
|
||||
rig.position += pivotPos + (head.rotation * headOffset);
|
||||
|
||||
// CONVERT TO LERPER
|
||||
// Shake
|
||||
boxShake = Vector3.Lerp(boxShake, (boxShake - boxOffset) * 0.5f, design.boxSpring * Time.deltaTime);
|
||||
boxOffset += boxShake * design.boxSpring * Time.deltaTime;
|
||||
transform.position += boxOffset;
|
||||
boxShake = Vector3.Lerp(boxShake, (boxShake - boxOffset) * 0.5f, 13 * Time.deltaTime);
|
||||
boxOffset += boxShake * 13 * Time.deltaTime;
|
||||
rig.position += boxOffset;
|
||||
|
||||
// Hanging Rod
|
||||
hangingRod.position = design.pivotPos;
|
||||
hangingRod.position = pivotPos;
|
||||
hangingRod.rotation = head.rotation;
|
||||
|
||||
// Record Cam
|
||||
|
@ -165,41 +181,3 @@ public class Rig : MonoBehaviour
|
|||
boxShake -= dir;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class Lerper
|
||||
{
|
||||
public float t = 0;
|
||||
public float spring = 1;
|
||||
public float dampen = 1;
|
||||
float vel;
|
||||
|
||||
public void Update(float to = 1, bool bounce = false)
|
||||
{
|
||||
float dir = to - t;
|
||||
vel += dir * spring * Time.deltaTime;
|
||||
|
||||
if (Mathf.Sign(vel) != Mathf.Sign(dir))
|
||||
{
|
||||
vel *= 1 - (dampen * Time.deltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
vel *= 1 - (dampen * 0.33f * Time.deltaTime);
|
||||
}
|
||||
|
||||
float newt = t + vel * Time.deltaTime;
|
||||
if (bounce && (newt < 0 || newt > 1))
|
||||
{
|
||||
vel *= -0.5f;
|
||||
newt = Mathf.Clamp01(newt);
|
||||
}
|
||||
|
||||
t = newt;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
t = vel = 0;
|
||||
}
|
||||
}
|
||||
|
|
41
Assets/Scripts/Tools.cs
Normal file
41
Assets/Scripts/Tools.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
// Put in Tools.cs (no Tool class tho)
|
||||
[Serializable]
|
||||
public class Lerper
|
||||
{
|
||||
public float t = 0;
|
||||
public float spring = 1;
|
||||
public float dampen = 1;
|
||||
float vel;
|
||||
|
||||
public void Update(float to = 1, bool bounce = false)
|
||||
{
|
||||
float dir = to - t;
|
||||
vel += dir * spring * Time.deltaTime;
|
||||
|
||||
if (Mathf.Sign(vel) != Mathf.Sign(dir))
|
||||
{
|
||||
vel *= 1 - (dampen * Time.deltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
vel *= 1 - (dampen * 0.33f * Time.deltaTime);
|
||||
}
|
||||
|
||||
float newt = t + vel * Time.deltaTime;
|
||||
if (bounce && (newt < 0 || newt > 1))
|
||||
{
|
||||
vel *= -0.5f;
|
||||
newt = Mathf.Clamp01(newt);
|
||||
}
|
||||
|
||||
t = newt;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
t = vel = 0;
|
||||
}
|
||||
}
|
11
Assets/Scripts/Tools.cs.meta
Normal file
11
Assets/Scripts/Tools.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2051c1d7a5067a54f94f55c13794474e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in a new issue