Compare commits
122 Commits
Author | SHA1 | Date | |
---|---|---|---|
f177384da3 | |||
![]() |
bfa05a93e3 | ||
![]() |
4d53839164 | ||
![]() |
0d22094ba4 | ||
![]() |
ab5d034f6e | ||
![]() |
9e7a685815 | ||
![]() |
fd9bc37467 | ||
![]() |
f1ef79a103 | ||
![]() |
6dcd64ddc7 | ||
fbfbb8cbaf | |||
90b4c46988 | |||
a3a2732060 | |||
![]() |
48f5a48639 | ||
![]() |
039b347475 | ||
![]() |
3d37b1a61e | ||
![]() |
c0effaf025 | ||
![]() |
66e07c9bdc | ||
![]() |
3a15ab000f | ||
![]() |
0a609ce083 | ||
![]() |
36660c8495 | ||
![]() |
70f9edc918 | ||
![]() |
c7c92f3e53 | ||
![]() |
d7c2f3b960 | ||
![]() |
27afc9d501 | ||
![]() |
f1a4ced59d | ||
![]() |
8b199b9c78 | ||
![]() |
ea9deb82fb | ||
![]() |
83ab3a6dbe | ||
![]() |
9e19dfd5af | ||
![]() |
c852dc4a1e | ||
![]() |
ddb76e71de | ||
![]() |
78a3d2f38a | ||
![]() |
0d6446ae18 | ||
9e5916d06c | |||
![]() |
3c853c3ba1 | ||
![]() |
9489cdc5b5 | ||
![]() |
46da2dfe1b | ||
![]() |
65aad9159e | ||
![]() |
c0256f8c9b | ||
![]() |
eeb74e2491 | ||
![]() |
bf7cd6c188 | ||
![]() |
64e5a573cb | ||
![]() |
43edc40b53 | ||
411b97e33d | |||
27fc3b7eb6 | |||
ff47263fce | |||
0cdbfadfa5 | |||
227c242589 | |||
9b31c9a7d3 | |||
81b7fee9ea | |||
285aefc2ae | |||
64af1d26da | |||
efefc4b9fd | |||
14ac81f2f2 | |||
43bd355b29 | |||
dc166b9246 | |||
143add636f | |||
0cb43c31d0 | |||
14d30d28e3 | |||
115fe62c49 | |||
ba8d8cf6e0 | |||
![]() |
bc6d236e1a | ||
![]() |
5d2459979c | ||
![]() |
e33f599371 | ||
![]() |
927dfff7d1 | ||
![]() |
e3ea1ce371 | ||
![]() |
31583b828a | ||
![]() |
3d340c4312 | ||
![]() |
178d242762 | ||
![]() |
34c45dc39a | ||
![]() |
c013cf0722 | ||
![]() |
f19acc5133 | ||
![]() |
71075deb47 | ||
![]() |
816bad12c2 | ||
![]() |
3f3f7f4d77 | ||
![]() |
6c0170e4cf | ||
0174e943e7 | |||
8e768343d8 | |||
cfde4632cd | |||
![]() |
5138587eef | ||
![]() |
d3cafd3c15 | ||
![]() |
a69e74e853 | ||
![]() |
724dd8a07a | ||
![]() |
c4bd28c4e7 | ||
![]() |
1e616284c0 | ||
![]() |
d2fe125488 | ||
![]() |
7c46b252dd | ||
![]() |
a7498aeb9f | ||
9093521f43 | |||
aa61ffd2f4 | |||
![]() |
43cf7767c4 | ||
![]() |
750fccaaaa | ||
6d3c7edd0d | |||
e991920a18 | |||
![]() |
8769d7328f | ||
![]() |
ab36bea0a7 | ||
![]() |
17f8325b37 | ||
![]() |
a5d3dc6938 | ||
![]() |
2f458dde27 | ||
![]() |
3e448bc472 | ||
![]() |
70e9210167 | ||
![]() |
a69f8c4eac | ||
![]() |
277662d107 | ||
![]() |
0bacb58481 | ||
![]() |
cde1f4b594 | ||
![]() |
fc79ea1a39 | ||
![]() |
af0fc71edd | ||
![]() |
2ab022b22b | ||
![]() |
5e4d59d30a | ||
![]() |
6c94ef65f8 | ||
![]() |
870b5a5546 | ||
![]() |
78a3a5119f | ||
![]() |
1704c4bc05 | ||
![]() |
77c9e37aef | ||
![]() |
4d7ab052a2 | ||
![]() |
80ab32d237 | ||
![]() |
ff63a67d9a | ||
![]() |
78cb4e4044 | ||
![]() |
4eb1f1722d | ||
![]() |
e646ef0f7d | ||
2b055edb6c | |||
![]() |
f99b3b9842 |
5
.gitignore
vendored
5
.gitignore
vendored
@ -0,0 +1,5 @@
|
||||
Samples
|
||||
Samples.meta
|
||||
package.json
|
||||
package.json.meta
|
||||
Samples~.meta
|
@ -1023,7 +1023,7 @@ namespace Passer.Humanoid {
|
||||
}
|
||||
|
||||
private static void CheckFaceTracking(Configuration configuration) {
|
||||
if (IsFileAvailable(facePath)) {
|
||||
if (DoesTypeExist("Passer.Humanoid.FaceTarget")) {
|
||||
GlobalDefine("hFACE");
|
||||
}
|
||||
else {
|
||||
@ -1120,6 +1120,9 @@ namespace Passer.Humanoid {
|
||||
return false;
|
||||
if (ConfigurationCheck.packageNameList.Contains("com.unity.xr.management"))
|
||||
return true;
|
||||
else if (ConfigurationCheck.packageNameList.Contains("com.unity.xr.oculus"))
|
||||
// Somehow management is no longer available when Oculus is used
|
||||
return true;
|
||||
else if (ConfigurationCheck.packageNameList.Contains("com.unity.xr.openxr"))
|
||||
// Somehow management is no longer available when OpenXR is used
|
||||
return true;
|
||||
|
@ -76,7 +76,7 @@ namespace Passer.Humanoid {
|
||||
Debug.Log(questManifestPath);
|
||||
File.Copy(questManifestPath, manifestPath);
|
||||
}
|
||||
catch (System.Exception _) {
|
||||
catch (System.Exception ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -855,6 +855,7 @@ namespace Passer {
|
||||
else {
|
||||
humanoid.pose.Show(humanoid);
|
||||
humanoid.CopyRigToTargets();
|
||||
humanoid.MatchTargetsToAvatar();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,8 @@ namespace Passer.Humanoid {
|
||||
}
|
||||
|
||||
public static GameObject GetHumanoidPlayerPrefab(string prefabPath) {
|
||||
GameObject prefab = PrefabUtility.LoadPrefabContents(prefabPath);
|
||||
//GameObject prefab = PrefabUtility.LoadPrefabContents(prefabPath);
|
||||
GameObject prefab = null;
|
||||
return prefab;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7ce8a0ec51c72a4f8a8f33325b0c51e
|
||||
guid: 875a66c1e6398184192242a8674906b3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
@ -0,0 +1,143 @@
|
||||
using UnityEngine;
|
||||
#if hPHOTON2
|
||||
using Photon.Pun;
|
||||
#if hPUNVOICE2 && !UNITY_WEBGL
|
||||
using Photon.Voice.PUN;
|
||||
using Photon.Voice.Unity;
|
||||
#endif
|
||||
#endif
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace Passer.Humanoid {
|
||||
|
||||
[InitializeOnLoad]
|
||||
public class OnLoadHumanoidPlayerPun {
|
||||
static OnLoadHumanoidPlayerPun() {
|
||||
CheckHumanoidPlayer();
|
||||
}
|
||||
|
||||
protected static void CheckHumanoidPlayerVoice() {
|
||||
#if hPUNVOICE2
|
||||
string prefabPath = OnLoadHumanoidPlayer.GetHumanoidPlayerPrefabPath();
|
||||
prefabPath = prefabPath.Substring(0, prefabPath.Length - 21) + "HumanoidPlayerVoice.prefab";
|
||||
GameObject playerVoicePrefab = OnLoadHumanoidPlayer.GetHumanoidPlayerPrefab(prefabPath);
|
||||
if (playerVoicePrefab == null)
|
||||
return;
|
||||
|
||||
bool hasChanged = false;
|
||||
#if UNITY_WEBGL
|
||||
PhotonView photonView = playerVoicePrefab.GetComponent<PhotonView>();
|
||||
if (photonView == null) {
|
||||
photonView = playerVoicePrefab.AddComponent<PhotonView>();
|
||||
hasChanged = true;
|
||||
}
|
||||
#else
|
||||
PhotonVoiceView photonVoiceView = playerVoicePrefab.GetComponent<PhotonVoiceView>();
|
||||
if (photonVoiceView == null) {
|
||||
photonVoiceView = playerVoicePrefab.AddComponent<PhotonVoiceView>();
|
||||
hasChanged = true;
|
||||
}
|
||||
if (photonVoiceView.UsePrimaryRecorder == false) {
|
||||
photonVoiceView.UsePrimaryRecorder = true;
|
||||
hasChanged = true;
|
||||
}
|
||||
PhotonTransformView photonTransformView = playerVoicePrefab.GetComponent<PhotonTransformView>();
|
||||
if (photonTransformView == null) {
|
||||
photonTransformView = playerVoicePrefab.AddComponent<PhotonTransformView>();
|
||||
hasChanged = true;
|
||||
}
|
||||
PhotonView photonView = playerVoicePrefab.GetComponent<PhotonView>();
|
||||
if (photonView != null) {
|
||||
// should always be there because of the photonVoiceView
|
||||
if (photonView.ObservedComponents == null) {
|
||||
photonView.ObservedComponents = new System.Collections.Generic.List<Component>();
|
||||
photonView.ObservedComponents.Add(photonTransformView);
|
||||
photonView.Synchronization = ViewSynchronization.UnreliableOnChange;
|
||||
hasChanged = true;
|
||||
}
|
||||
}
|
||||
//Speaker speaker = playerVoicePrefab.GetComponent<Speaker>();
|
||||
//if (speaker == null) {
|
||||
// speaker = playerVoicePrefab.AddComponent<Speaker>();
|
||||
// photonVoiceView.SpeakerInUse = speaker;
|
||||
// hasChanged = true;
|
||||
|
||||
// AudioSource audioSource = playerVoicePrefab.GetComponent<AudioSource>();
|
||||
// if (audioSource != null) {
|
||||
// Debug.Log("adjust rolloff");
|
||||
// // default logaritmic only work when people are closer than 0.5m...
|
||||
// audioSource.maxDistance = 5;
|
||||
// }
|
||||
//}
|
||||
#endif
|
||||
if (hasChanged)
|
||||
OnLoadHumanoidPlayer.UpdateHumanoidPrefab(playerVoicePrefab, prefabPath);
|
||||
#if !UNITY_WEBGL
|
||||
CheckVoiceNetwork();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#if hPUNVOICE2 && !UNITY_WEBGL
|
||||
protected static void CheckVoiceNetwork() {
|
||||
NetworkingStarter networkingStarter = Object.FindObjectOfType<NetworkingStarter>();
|
||||
if (networkingStarter == null)
|
||||
return;
|
||||
|
||||
PhotonVoiceNetwork voiceNetwork = Object.FindObjectOfType<PhotonVoiceNetwork>();
|
||||
if (voiceNetwork != null)
|
||||
return;
|
||||
|
||||
GameObject voiceNetworkObject = new GameObject("Voice Network");
|
||||
voiceNetwork = voiceNetworkObject.AddComponent<PhotonVoiceNetwork>();
|
||||
|
||||
Recorder voiceRecorder = voiceNetworkObject.AddComponent<Recorder>();
|
||||
voiceRecorder.ReactOnSystemChanges = true;
|
||||
voiceRecorder.TransmitEnabled = true;
|
||||
voiceRecorder.SamplingRate = POpusCodec.Enums.SamplingRate.Sampling48000;
|
||||
|
||||
voiceNetwork.PrimaryRecorder = voiceRecorder;
|
||||
}
|
||||
#endif
|
||||
|
||||
public static void CheckHumanoidPlayer() {
|
||||
#if hPHOTON1 || hPHOTON2
|
||||
string prefabPath = OnLoadHumanoidPlayer.GetHumanoidPlayerPrefabPath();
|
||||
GameObject playerPrefab = OnLoadHumanoidPlayer.GetHumanoidPlayerPrefab(prefabPath);
|
||||
|
||||
bool hasChanged = false;
|
||||
#if hNW_PHOTON
|
||||
if (playerPrefab != null) {
|
||||
PhotonView photonView = playerPrefab.GetComponent<PhotonView>();
|
||||
if (photonView == null) {
|
||||
photonView = playerPrefab.AddComponent<PhotonView>();
|
||||
photonView.ObservedComponents = new System.Collections.Generic.List<Component>();
|
||||
#if hPHOTON2
|
||||
photonView.Synchronization = ViewSynchronization.UnreliableOnChange;
|
||||
#else
|
||||
photonView.synchronization = ViewSynchronization.UnreliableOnChange;
|
||||
#endif
|
||||
|
||||
HumanoidPlayer humanoidPun = playerPrefab.GetComponent<HumanoidPlayer>();
|
||||
if (humanoidPun != null)
|
||||
photonView.ObservedComponents.Add(humanoidPun);
|
||||
hasChanged = true;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (playerPrefab != null) {
|
||||
PhotonView photonView = playerPrefab.GetComponent<PhotonView>();
|
||||
if (photonView != null)
|
||||
Object.DestroyImmediate(photonView, true);
|
||||
}
|
||||
#endif
|
||||
if (hasChanged)
|
||||
OnLoadHumanoidPlayer.UpdateHumanoidPrefab(playerPrefab, prefabPath);
|
||||
#endif
|
||||
CheckHumanoidPlayerVoice();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 185ec4e1799d1ac4d867b69454f1cd0f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
108
Editor/HumanoidControl/Networking/PhotonPun/PunStarter_Editor.cs
Normal file
108
Editor/HumanoidControl/Networking/PhotonPun/PunStarter_Editor.cs
Normal file
@ -0,0 +1,108 @@
|
||||
/*
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
#if hNW_PHOTON
|
||||
#if hPHOTON2
|
||||
using Photon.Pun;
|
||||
#endif
|
||||
|
||||
namespace Passer {
|
||||
|
||||
[CustomEditor(typeof(PhotonStarter))]
|
||||
public class PunStarter_Editor : Editor {
|
||||
|
||||
public override void OnInspectorGUI() {
|
||||
base.OnInspectorGUI();
|
||||
|
||||
HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>();
|
||||
if (humanoids.Length != 1)
|
||||
// We only support sitatuation with one humanoid in the scene
|
||||
return;
|
||||
|
||||
//HumanoidControl humanoid = humanoids[0];
|
||||
|
||||
if (Application.isPlaying)
|
||||
return;
|
||||
|
||||
//GameObject humanoidPrefab = CheckHumanoidPrefab(humanoid);
|
||||
//NetworkingComponentsInspectorPun(humanoid, humanoidPrefab);
|
||||
}
|
||||
|
||||
//private GameObject CheckHumanoidPrefab(HumanoidControl humanoid) {
|
||||
// GameObject humanoidPrefab = Resources.Load<GameObject>(humanoid.gameObject.name + "_generated");
|
||||
// if (humanoidPrefab == null) {
|
||||
// humanoidPrefab = PrefabUtility.CreatePrefab("Assets/Humanoid/Prefabs/Networking/Resources/" + humanoid.gameObject.name + "_generated.prefab", humanoid.gameObject);
|
||||
// humanoidPrefab.gameObject.SetActive(true);
|
||||
// }
|
||||
// return humanoidPrefab;
|
||||
//}
|
||||
|
||||
//private void UpdateHumanoidPrefab(HumanoidControl humanoid) {
|
||||
// if (humanoid != null) {
|
||||
// GameObject humanoidPrefab = Resources.Load<GameObject>(humanoid.gameObject.name + "_generated");
|
||||
// if (humanoidPrefab != null && humanoid.gameObject != humanoidPrefab)
|
||||
// PrefabUtility.ReplacePrefab(humanoid.gameObject, humanoidPrefab, ReplacePrefabOptions.ConnectToPrefab);
|
||||
// }
|
||||
//}
|
||||
|
||||
// private void NetworkingComponentsInspectorPun(HumanoidControl humanoid, GameObject humanoidPrefab) {
|
||||
//#if hPHOTON1 || hPHOTON2
|
||||
//#if hNW_PHOTON
|
||||
// CheckPunStarter(humanoid, humanoidPrefab);
|
||||
// PhotonView photonView = humanoid.GetComponent<PhotonView>();
|
||||
// if (photonView == null)
|
||||
// photonView = humanoid.gameObject.AddComponent<PhotonView>();
|
||||
// photonView.ObservedComponents = new System.Collections.Generic.List<Component>();
|
||||
// photonView.ObservedComponents.Add(humanoid);
|
||||
//#else
|
||||
// cleanupPhotonView = humanoid.GetComponent<PhotonView>();
|
||||
//#endif
|
||||
//#endif
|
||||
// }
|
||||
|
||||
// private void CheckPunStarter(HumanoidControl humanoid, GameObject humanoidPrefab) {
|
||||
// if (Application.isPlaying)
|
||||
// return;
|
||||
|
||||
//#if hNW_PHOTON
|
||||
// PhotonStarter photonStarter = FindObjectOfType<PhotonStarter>();
|
||||
// if (photonStarter != null && humanoidPrefab != null && photonStarter.playerPrefab != humanoidPrefab) {
|
||||
// Undo.RecordObject(photonStarter, "Updated Player Prefab");
|
||||
// photonStarter.playerPrefab = humanoidPrefab;
|
||||
// }
|
||||
//#endif
|
||||
// }
|
||||
public void OnDisable() {
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
#if hNW_UNET
|
||||
private NetworkIdentity cleanupNetworkIdentity;
|
||||
#endif
|
||||
#if hPHOTON1 || hPHOTON2
|
||||
private PhotonView cleanupPhotonView;
|
||||
#endif
|
||||
private GameObject cleanupPunStarter;
|
||||
private void Cleanup() {
|
||||
#if hNW_UNET
|
||||
if (cleanupNetworkIdentity) {
|
||||
DestroyImmediate(cleanupNetworkIdentity, true);
|
||||
cleanupNetworkIdentity = null;
|
||||
}
|
||||
#endif
|
||||
#if hPHOTON1 || hPHOTON2
|
||||
if (cleanupPhotonView) {
|
||||
DestroyImmediate(cleanupPhotonView, true);
|
||||
cleanupPhotonView = null;
|
||||
}
|
||||
#endif
|
||||
if (cleanupPunStarter) {
|
||||
DestroyImmediate(cleanupPunStarter, true);
|
||||
cleanupPunStarter = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
*/
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e86563dd015c559479420645216c4a70
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -236,7 +236,13 @@ namespace Passer.Humanoid {
|
||||
if (bones[i] == null || bones[i].bone == null || bones[i].bone.transform == null)
|
||||
continue;
|
||||
|
||||
#if UNITY_2022_1_OR_NEWER
|
||||
Handles.FreeMoveHandle(bones[i].bone.transform.position, 0.002F, Vector3.zero, DotHandleCapSaveID);
|
||||
#else
|
||||
Handles.FreeMoveHandle(bones[i].bone.transform.position, bones[i].bone.transform.rotation, 0.002F, Vector3.zero, DotHandleCapSaveID);
|
||||
#endif
|
||||
|
||||
|
||||
controlIds[i] = lastControlID;
|
||||
boneIds[i] = bones[i].boneId;
|
||||
}
|
||||
@ -317,6 +323,6 @@ namespace Passer.Humanoid {
|
||||
return;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -63,9 +63,9 @@ namespace Passer {
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Disable
|
||||
#region Disable
|
||||
public void OnDisable() {
|
||||
if (humanoid == null) {
|
||||
// This target is not connected to a humanoid, so we delete it
|
||||
@ -82,9 +82,9 @@ namespace Passer {
|
||||
foreach (TargetProps props in allProps)
|
||||
props.SetSensor2Target();
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Inspector
|
||||
#region Inspector
|
||||
public override void OnInspectorGUI() {
|
||||
if (footTarget == null || humanoid == null)
|
||||
return;
|
||||
@ -142,7 +142,7 @@ namespace Passer {
|
||||
return foundHumanoid;
|
||||
}
|
||||
|
||||
#region Sensors
|
||||
#region Sensors
|
||||
private static bool showControllers = true;
|
||||
private void ControllerInspectors(FootTarget footTarget) {
|
||||
showControllers = EditorGUILayout.Foldout(showControllers, "Controllers", true);
|
||||
@ -157,9 +157,9 @@ namespace Passer {
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Configuration
|
||||
#region Configuration
|
||||
private void InitConfiguration(FootTarget footTarget) {
|
||||
if (footTarget.humanoid.avatarRig == null)
|
||||
return;
|
||||
@ -200,7 +200,7 @@ namespace Passer {
|
||||
UpdateToesBones(target.toes);
|
||||
}
|
||||
|
||||
#region UpperLeg
|
||||
#region UpperLeg
|
||||
//private string upperLegXname;
|
||||
//private SerializedProperty upperLegMinX;
|
||||
//private SerializedProperty upperLegMaxX;
|
||||
@ -276,9 +276,9 @@ namespace Passer {
|
||||
//upperLeg.bone.maxAngles.z = upperLegMaxZ.floatValue;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region LowerLeg
|
||||
#region LowerLeg
|
||||
//private string lowerLegYname;
|
||||
//private SerializedProperty lowerLegMinX;
|
||||
//private SerializedProperty lowerLegMaxX;
|
||||
@ -326,9 +326,9 @@ namespace Passer {
|
||||
//lowerLeg.bone.minAngles.x = lowerLegMinX.floatValue;
|
||||
//lowerLeg.bone.maxAngles.x = lowerLegMaxX.floatValue;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Foot
|
||||
#region Foot
|
||||
//private string footXname;
|
||||
//private SerializedProperty footMinX;
|
||||
//private SerializedProperty footMaxX;
|
||||
@ -390,9 +390,9 @@ namespace Passer {
|
||||
//foot.bone.minAngles.z = footMinZ.floatValue;
|
||||
//foot.bone.maxAngles.z = footMaxZ.floatValue;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Toes
|
||||
#region Toes
|
||||
//private string toesXname;
|
||||
//private SerializedProperty toesMinX;
|
||||
//private SerializedProperty toesMaxX;
|
||||
@ -441,10 +441,10 @@ namespace Passer {
|
||||
//toes.bone.maxAngles.x = toesMaxX.floatValue;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Settings
|
||||
#region Settings
|
||||
private SerializedProperty rotationSpeedLimitationProp;
|
||||
private SerializedProperty slidePreventionProp;
|
||||
|
||||
@ -470,9 +470,9 @@ namespace Passer {
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
#region Events
|
||||
|
||||
protected SerializedProperty groundEventProp;
|
||||
|
||||
@ -534,11 +534,11 @@ namespace Passer {
|
||||
// }
|
||||
//}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Scene
|
||||
#region Scene
|
||||
|
||||
public void OnSceneGUI() {
|
||||
if (footTarget == null || humanoid == null)
|
||||
@ -551,12 +551,13 @@ namespace Passer {
|
||||
humanoid.pose.UpdatePose(humanoid);
|
||||
else {
|
||||
humanoid.pose.Show(humanoid);
|
||||
footTarget.CopyRigToTarget();
|
||||
humanoid.CopyRigToTargets();
|
||||
humanoid.MatchTargetsToAvatar();
|
||||
}
|
||||
}
|
||||
|
||||
// update the target rig from the current foot target
|
||||
footTarget.CopyTargetToRig();
|
||||
humanoid.CopyTargetsToRig();
|
||||
// update the avatar bones from the target rig
|
||||
humanoid.UpdateMovements();
|
||||
// match the target rig with the new avatar pose
|
||||
@ -568,7 +569,7 @@ namespace Passer {
|
||||
humanoid.UpdateSensorsFromTargets();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
public abstract class TargetProps {
|
||||
public SerializedProperty enabledProp;
|
||||
|
@ -145,8 +145,6 @@ namespace Passer.Humanoid {
|
||||
InteractionPointerButton(handTarget);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
//serializedObject.Update();
|
||||
//serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
public static HandTarget Inspector(HandTarget handTarget, string name) {
|
||||
@ -439,8 +437,8 @@ namespace Passer.Humanoid {
|
||||
if (showSettings) {
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
// Cannot use serializedPropery because showRealObjects is a getter/setter
|
||||
bool showRealObjects = EditorGUILayout.Toggle("Show Real Objects", handTarget.showRealObjects);
|
||||
SerializedProperty showObjectsProp = serializedObject.FindProperty("_showRealObjects");
|
||||
bool showRealObjects = EditorGUILayout.Toggle("Show Real Objects", showObjectsProp.boolValue);
|
||||
if (showRealObjects != handTarget.showRealObjects) {
|
||||
handTarget.showRealObjects = showRealObjects;
|
||||
handTarget.ShowSensors(showRealObjects, true);
|
||||
@ -697,12 +695,13 @@ namespace Passer.Humanoid {
|
||||
humanoid.pose.UpdatePose(humanoid);
|
||||
else {
|
||||
humanoid.pose.Show(humanoid);
|
||||
handTarget.CopyRigToTarget();
|
||||
humanoid.CopyRigToTargets();
|
||||
humanoid.MatchTargetsToAvatar();
|
||||
}
|
||||
}
|
||||
|
||||
// update the target rig from the current hand target
|
||||
handTarget.CopyTargetToRig();
|
||||
humanoid.CopyTargetsToRig();
|
||||
// update the avatar bones from the target rig
|
||||
humanoid.UpdateMovements();
|
||||
// match the target rig with the new avatar pose
|
||||
|
@ -275,7 +275,7 @@ namespace Passer.Humanoid {
|
||||
if (headTarget.humanoid == null)
|
||||
return;
|
||||
|
||||
SerializedProperty animatorProp = serializedObject.FindProperty(nameof(HeadTarget.headAnimator)+ "." +nameof(HeadTarget.headAnimator.enabled));
|
||||
SerializedProperty animatorProp = serializedObject.FindProperty(nameof(HeadTarget.headAnimator) + "." + nameof(HeadTarget.headAnimator.enabled));
|
||||
if (animatorProp != null && headTarget.humanoid.animatorEnabled) {
|
||||
|
||||
GUIContent text = new GUIContent(
|
||||
@ -482,12 +482,13 @@ namespace Passer.Humanoid {
|
||||
humanoid.pose.UpdatePose(humanoid);
|
||||
else {
|
||||
humanoid.pose.Show(humanoid);
|
||||
headTarget.CopyRigToTarget();
|
||||
humanoid.CopyRigToTargets();
|
||||
humanoid.MatchTargetsToAvatar();
|
||||
}
|
||||
}
|
||||
|
||||
// update the target rig from the current head target
|
||||
headTarget.CopyTargetToRig();
|
||||
humanoid.CopyTargetsToRig();
|
||||
// update the avatar bones from the target rig
|
||||
humanoid.UpdateMovements();
|
||||
// match the target rig with the new avatar pose
|
||||
|
@ -276,12 +276,13 @@ namespace Passer {
|
||||
humanoid.pose.UpdatePose(humanoid);
|
||||
else {
|
||||
humanoid.pose.Show(humanoid);
|
||||
hipsTarget.CopyRigToTarget();
|
||||
humanoid.CopyRigToTargets();
|
||||
humanoid.MatchTargetsToAvatar();
|
||||
}
|
||||
}
|
||||
|
||||
// update the target rig from the current hips target
|
||||
hipsTarget.CopyTargetToRig();
|
||||
humanoid.CopyTargetsToRig();
|
||||
// update the avatar bones to match the target rig
|
||||
humanoid.UpdateMovements();
|
||||
// match the target rig with the new avatar pose
|
||||
|
@ -4,6 +4,7 @@ using UnityEngine;
|
||||
namespace Passer {
|
||||
using Humanoid;
|
||||
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(Handle), true)]
|
||||
public class Handle_Editor : Editor {
|
||||
|
||||
@ -42,9 +43,14 @@ namespace Passer {
|
||||
//if (HumanoidPreferences.help)
|
||||
// EditorGUILayout.HelpBox("Component to specify behaviour when grabbing the GameObject", MessageType.None);
|
||||
|
||||
handle.hand = (Handle.Hand)EditorGUILayout.EnumPopup("Hand", handle.hand);
|
||||
handle.grabType = (Handle.GrabType)EditorGUILayout.EnumPopup("Grab type", handle.grabType);
|
||||
handle.range = EditorGUILayout.FloatField("Range", handle.range);
|
||||
SerializedProperty handProp = serializedObject.FindProperty(nameof(Handle.hand));
|
||||
handProp.intValue = (int)(Handle.Hand)EditorGUILayout.EnumPopup("Hand", (Handle.Hand)handProp.intValue);
|
||||
|
||||
SerializedProperty grabTypeProp = serializedObject.FindProperty(nameof(Handle.grabType));
|
||||
grabTypeProp.intValue = (int)(Handle.GrabType)EditorGUILayout.EnumPopup("Grab type", (Handle.GrabType)grabTypeProp.intValue);
|
||||
|
||||
SerializedProperty rangeProp = serializedObject.FindProperty(nameof(Handle.range));
|
||||
rangeProp.floatValue = EditorGUILayout.FloatField("Range", rangeProp.floatValue);
|
||||
|
||||
HandPoseInspector(handle);
|
||||
CheckHandTarget(handle);
|
||||
|
@ -4,7 +4,7 @@ using UnityEngine;
|
||||
namespace Passer {
|
||||
using Humanoid;
|
||||
|
||||
[CustomEditor(typeof(ControllerInput))]
|
||||
[CustomEditor(typeof(ControllerInput), true)]
|
||||
public class ControllerInput_Editor : Editor {
|
||||
protected ControllerInput controllerInput;
|
||||
|
||||
|
10
README.md
10
README.md
@ -4,19 +4,21 @@ You can import the Humanoid Control Free package in Unity directly with the Pack
|
||||
|
||||
See [Unity: Installing from a Git URL](https://docs.unity3d.com/Manual/upm-ui-giturl.html)
|
||||
|
||||
Use the link from 'Clone with HTTP' (for example: https://gitlab.passervr.com/passer/unity/humanoidcontrol4_free.git)
|
||||
Use the link from 'Clone with HTTP' (for example: https://git.passer.life/HumanoidControl/HumanoidControl_Free.git)
|
||||
In this way you can always retrieve the latest version by pressing the `Update` button in the Package Manager.
|
||||
|
||||
Optionally, you can use a tag to retrieve a specific version. For example:http://gitlab.passervr.com/passer/unity/humanoidcontrol4_free.git#4.1.0.
|
||||
Optionally, you can use a tag to retrieve a specific version. For example:https://git.passer.life/HumanoidControl/HumanoidControl_Free.git#4.1.0.
|
||||
This will give you a stable version which does not change. Updating can be done by retrieving the package with a link to a new release.
|
||||
|
||||
ChangeLog and Releases
|
||||
======================
|
||||
You will find all releases with UnityPackages and links for the Unity Package Manager in the [Releases](https://gitlab.passervr.com/passer/unity/humanoidcontrol4_free/-/releases)
|
||||
All releases with UnityPackages and links for the Unity Package Manager: [Tags page](https://git.passer.life/HumanoidControl/HumanoidControl_Free/tags).
|
||||
|
||||
An RSS/Atom feed with all releases can be found on the [Tags page](https://git.passer.life/HumanoidControl/HumanoidControl_Free/tags). Click on the _RSS Feed_ icon in the top-right corner to retrieve the feed.
|
||||
|
||||
Documentation
|
||||
=============
|
||||
For the latest version of the documentation, see [PasserVR HumanoidControl Documentation](https://passervr.com/apis/HumanoidControl/Unity/index.html)
|
||||
For the latest version of the documentation, see [PasserVR HumanoidControl Documentation](https://docs.humanoidcontrol.com/)
|
||||
|
||||
Video
|
||||
=====
|
||||
|
Binary file not shown.
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ddd35f516c607da4ab4f97b210606169
|
||||
timeCreated: 1453468358
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@ -1,27 +1,16 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1001 &100100000
|
||||
Prefab:
|
||||
m_ObjectHideFlags: 1
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications: []
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 0}
|
||||
m_RootGameObject: {fileID: 1547744635115364}
|
||||
m_IsPrefabParent: 1
|
||||
--- !u!1 &1102845541656492
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
serializedVersion: 5
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 224080167443833264}
|
||||
- component: {fileID: 222382479412892260}
|
||||
- component: {fileID: 114935358240423544}
|
||||
- component: {fileID: 114123306642843232}
|
||||
m_Layer: 0
|
||||
m_Name: Text
|
||||
m_TagString: Untagged
|
||||
@ -29,91 +18,53 @@ GameObject:
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!1 &1547744635115364
|
||||
GameObject:
|
||||
--- !u!224 &224080167443833264
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 224268792594220398}
|
||||
- component: {fileID: 223133106560874972}
|
||||
- component: {fileID: 114215111648024090}
|
||||
- component: {fileID: 114000307814322182}
|
||||
m_Layer: 0
|
||||
m_Name: NetworkingStatusCanvas
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &114000307814322182
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 1547744635115364}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 1301386320, guid: f70555f144d8491a825f0804e09c671c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_IgnoreReversedGraphics: 1
|
||||
m_BlockingObjects: 0
|
||||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
--- !u!114 &114123306642843232
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1102845541656492}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d7994b261fec79c4a9a1c329820642f3, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &114215111648024090
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 1547744635115364}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 1980459831, guid: f70555f144d8491a825f0804e09c671c, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_UiScaleMode: 0
|
||||
m_ReferencePixelsPerUnit: 100
|
||||
m_ScaleFactor: 1
|
||||
m_ReferenceResolution: {x: 800, y: 600}
|
||||
m_ScreenMatchMode: 0
|
||||
m_MatchWidthOrHeight: 0
|
||||
m_PhysicalUnit: 3
|
||||
m_FallbackScreenDPI: 96
|
||||
m_DefaultSpriteDPI: 96
|
||||
m_DynamicPixelsPerUnit: 1
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 224268792594220398}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 160, y: 30}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &222382479412892260
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1102845541656492}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &114935358240423544
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1102845541656492}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
|
||||
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
m_FontData:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_FontSize: 14
|
||||
@ -128,17 +79,51 @@ MonoBehaviour:
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: New Text
|
||||
--- !u!222 &222382479412892260
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 1102845541656492}
|
||||
--- !u!1 &1547744635115364
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 224268792594220398}
|
||||
- component: {fileID: 223133106560874972}
|
||||
- component: {fileID: 114215111648024090}
|
||||
- component: {fileID: 114000307814322182}
|
||||
m_Layer: 0
|
||||
m_Name: NetworkingStatusCanvas
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &224268792594220398
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1547744635115364}
|
||||
m_LocalRotation: {x: -0.0000015646192, y: -0.0000072655666, z: -0.0000067270753, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0.5}
|
||||
m_LocalScale: {x: 0.001, y: 0.001, z: 0.001}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 224080167443833264}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 160, y: 40}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!223 &223133106560874972
|
||||
Canvas:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1547744635115364}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 3
|
||||
@ -150,45 +135,49 @@ Canvas:
|
||||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 25
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
m_TargetDisplay: 0
|
||||
--- !u!224 &224080167443833264
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 1102845541656492}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 224268792594220398}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 160, y: 30}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!224 &224268792594220398
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
--- !u!114 &114215111648024090
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1547744635115364}
|
||||
m_LocalRotation: {x: -0.0000015646192, y: -0.0000072655666, z: -0.0000067270753,
|
||||
w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0.5}
|
||||
m_LocalScale: {x: 0.001, y: 0.001, z: 0.001}
|
||||
m_Children:
|
||||
- {fileID: 224080167443833264}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 160, y: 40}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_UiScaleMode: 0
|
||||
m_ReferencePixelsPerUnit: 100
|
||||
m_ScaleFactor: 1
|
||||
m_ReferenceResolution: {x: 800, y: 600}
|
||||
m_ScreenMatchMode: 0
|
||||
m_MatchWidthOrHeight: 0
|
||||
m_PhysicalUnit: 3
|
||||
m_FallbackScreenDPI: 96
|
||||
m_DefaultSpriteDPI: 96
|
||||
m_DynamicPixelsPerUnit: 1
|
||||
m_PresetInfoIsWorld: 0
|
||||
--- !u!114 &114000307814322182
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1547744635115364}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_IgnoreReversedGraphics: 1
|
||||
m_BlockingObjects: 0
|
||||
m_BlockingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -13,7 +13,7 @@ namespace Passer.Humanoid {
|
||||
}
|
||||
public BodyRotation bodyRotation;
|
||||
|
||||
private float torsoLength;
|
||||
protected float torsoLength;
|
||||
|
||||
private Quaternion torsoUprightOrientation;
|
||||
|
||||
@ -67,7 +67,7 @@ namespace Passer.Humanoid {
|
||||
private Vector3 leftFootPosition;
|
||||
private Quaternion rightFootRotation;
|
||||
private Vector3 rightFootPosition;
|
||||
private void StoreTargets() {
|
||||
public void StoreTargets() {
|
||||
neckRotation = hipsTarget.humanoid.headTarget.neck.target.transform.rotation;
|
||||
neckPosition = hipsTarget.humanoid.headTarget.neck.target.transform.position;
|
||||
leftHandRotation = hipsTarget.humanoid.leftHandTarget.hand.target.transform.rotation;
|
||||
@ -80,7 +80,7 @@ namespace Passer.Humanoid {
|
||||
rightFootPosition = hipsTarget.humanoid.rightFootTarget.foot.target.transform.localPosition;
|
||||
}
|
||||
|
||||
private void RestoreTargets() {
|
||||
public void RestoreTargets() {
|
||||
hipsTarget.humanoid.headTarget.neck.target.transform.rotation = neckRotation;
|
||||
hipsTarget.humanoid.headTarget.neck.target.transform.position = neckPosition;
|
||||
hipsTarget.humanoid.leftHandTarget.hand.target.transform.rotation = leftHandRotation;
|
||||
@ -177,7 +177,7 @@ namespace Passer.Humanoid {
|
||||
oldPosition = neckPosition;
|
||||
}
|
||||
|
||||
private Vector3 CalculateHipsPosition() {
|
||||
public Vector3 CalculateHipsPosition() {
|
||||
HumanoidControl humanoid = hipsTarget.humanoid;
|
||||
HeadTarget headTarget = humanoid.headTarget;
|
||||
|
||||
|
@ -6,8 +6,95 @@ namespace Passer.Humanoid {
|
||||
/// <summary>
|
||||
/// A tracker wich can be used for custom tracking solutions
|
||||
/// </summary>
|
||||
/// THis tracking option supports custom trackers and sensors for a humanoid.
|
||||
[System.Serializable]
|
||||
/// This tracking option supports custom trackers and sensors for a humanoid.
|
||||
/// We support two types of tracking
|
||||
/// - using a BodySkeleton
|
||||
/// - using SensorComponent
|
||||
///
|
||||
/// BodySkeleton
|
||||
/// ------------
|
||||
/// This option is most suited for full body tracking hardware.
|
||||
/// An example implementation is the PerceptionNeuron extension found in the %Humanoid Control Pro edition.
|
||||
///
|
||||
/// For this, you need to implement a class derived from the Passer::Tracking::BodySkeleton class.
|
||||
/// For the Perception Neuron extension, this new class is Passer::Tracking::PerceptionNeuron.
|
||||
/// This class should be used for the to the CustomTracker::bodySkeleton parameter:
|
||||
/// \image html CustomTrackerBodySkeleton.png
|
||||
/// \image rtf CustomTrackerBodySkeleton.png
|
||||
/// In the new class, you should override the Passer::Tracking::BodySkeleton::Start
|
||||
/// and Passer::Tracking::BodySkeleton::Update functions
|
||||
/// and implement the functionality to correctly start the tracking and retrieving the new body pose.
|
||||
/// This will ensure that the tracking is started and updated at the right moment.
|
||||
/// In the update function, you can asssign the tracking result to the correct tracking bones
|
||||
/// of %Humanoid Control.
|
||||
/// You can retrieve the %Humanoid Control TrackedBone using the BodySkeleton::GetBone function.
|
||||
/// Then you can update the position and/or the rotation of the bone.
|
||||
///
|
||||
/// *Important*: a confidence value between 0 and 1 should also be set for the bone's position and/or rotation.
|
||||
/// The default confidence is 0 and in that case, the tracking information will not be used.
|
||||
/// Next to that, the Passer::Tracking::BodySkeleton::status should reflect the current tracking status of the device.
|
||||
///
|
||||
/// Example of updating one bone:
|
||||
/// \code
|
||||
/// protected void UpdateBone(Bone boneId) {
|
||||
/// TrackedBone bone = GetBone(boneId);
|
||||
/// if (bone == null)
|
||||
/// return;
|
||||
///
|
||||
/// // Get Perception Neuron tracking information
|
||||
/// SensorBone neuronBone = device.GetBone(0, boneId);
|
||||
///
|
||||
/// // Assign the tracking position
|
||||
/// bone.transform.position = neuronBone.position;
|
||||
/// // Set the position Confidence
|
||||
/// bone.positionConfidence = neuronBone.positionConfidence;
|
||||
///
|
||||
/// // Assign the tracking rotation
|
||||
/// bone.transform.rotation = neuronBone.rotation;;
|
||||
/// // Set the rotation Confidence
|
||||
/// bone.rotationConfidence = neuronBone.rotationConfidence;
|
||||
/// }
|
||||
/// \endcode
|
||||
///
|
||||
/// SensorComponents
|
||||
/// ================
|
||||
/// This option is most suited for tracking devices which can be mounted on the body.
|
||||
/// An example implementation is the ViveTracker imnplementation found in the %Humanoid Control Pro edition.
|
||||
///
|
||||
/// For this, you need to implement a class derived from the SensorComponent class.
|
||||
/// For the ViveTracker, this is the Passer::Tracking::ViveTrackerComponent.
|
||||
/// This class should be used on the Head, Hand, Hips and/or Foot Targets in the Sensor::sensorComponent
|
||||
/// parameter. Where applicable, selecting the bone in the dropdown determine to which bone the device is attached.
|
||||
/// \image html CustomTrackerSensorComponent.png
|
||||
/// \image rtf CustomTrackerSensorComponent.png
|
||||
/// In the new class, you should override the SensorComponent::StartComponent and SensorComponent::UpdateComponent functions
|
||||
/// and implement the functionality to correctly start the tracking and retrieve the actual pose of the device.
|
||||
/// This will ensure that the tracking is started and updated at the right moment.
|
||||
///
|
||||
/// In the overridden SensorUpdate function, you should update the Transform of the SensorComponent.
|
||||
///
|
||||
/// *Important*: a confidence value between 0 and 1 should also be set for the device.
|
||||
/// The default confidence is 0 and in that case, the tracking information will not be used.
|
||||
/// Next to that, the SensorComponent::status should reflect the current tracking status of the device.
|
||||
/// Example of updating the device rotation and position:
|
||||
/// \code
|
||||
/// public override void UpdateComponent() {
|
||||
/// if (actionPose.poseIsValid) {
|
||||
/// transform.localPosition = actionPose.localPosition;
|
||||
/// transform.localRotation = actionPose.localRotation;
|
||||
///
|
||||
/// status = Tracker.Status.Tracking;
|
||||
/// positionConfidence = 0.99F;
|
||||
/// rotationConfidence = 0.99F;
|
||||
/// }
|
||||
/// else {
|
||||
/// status = Tracker.Status.Present;
|
||||
/// positionConfidence = 0F;
|
||||
/// rotationConfidence = 0F;
|
||||
/// }
|
||||
/// }
|
||||
/// \endcode
|
||||
[System.Serializable]
|
||||
public class CustomTracker : HumanoidTracker {
|
||||
|
||||
/// \copydoc HumanoidTracker::name
|
||||
|
@ -86,7 +86,7 @@ namespace Passer.Tracking {
|
||||
}
|
||||
|
||||
if (OculusDevice.GetHandState(OculusDevice.Step.Render, isLeft ? OculusDevice.Hand.HandLeft : OculusDevice.Hand.HandRight, ref handState)) {
|
||||
if (handState.Status == 0) {
|
||||
if ((handState.Status & OculusDevice.HandStatus.HandTracked) == 0) {
|
||||
status = Tracker.Status.Present;
|
||||
DisableRenderer();
|
||||
return;
|
||||
|
@ -1,84 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1001 &100100000
|
||||
Prefab:
|
||||
m_ObjectHideFlags: 1
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications: []
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 0}
|
||||
m_RootGameObject: {fileID: 1103073703406032}
|
||||
m_IsPrefabParent: 1
|
||||
--- !u!1 &1103073703406032
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 4808734570168326}
|
||||
- component: {fileID: 33781626903072926}
|
||||
- component: {fileID: 23539047341558740}
|
||||
m_Layer: 0
|
||||
m_Name: Left Quest Controller
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &4808734570168326
|
||||
Transform:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 1103073703406032}
|
||||
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: -0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!23 &23539047341558740
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 1103073703406032}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: dc3b3568b7c54234f9d6a9f7297c3425, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 0
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
--- !u!33 &33781626903072926
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 1103073703406032}
|
||||
m_Mesh: {fileID: 4300000, guid: a533ecc148345874ca68507932792b9e, type: 3}
|
@ -1,84 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1001 &100100000
|
||||
Prefab:
|
||||
m_ObjectHideFlags: 1
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications: []
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 0}
|
||||
m_RootGameObject: {fileID: 1038420493408916}
|
||||
m_IsPrefabParent: 1
|
||||
--- !u!1 &1038420493408916
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
serializedVersion: 5
|
||||
m_Component:
|
||||
- component: {fileID: 4210319229959686}
|
||||
- component: {fileID: 33256649974969318}
|
||||
- component: {fileID: 23472074526415768}
|
||||
m_Layer: 0
|
||||
m_Name: Right Quest Controller
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &4210319229959686
|
||||
Transform:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 1038420493408916}
|
||||
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: -0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!23 &23472074526415768
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 1038420493408916}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: dc3b3568b7c54234f9d6a9f7297c3425, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 0
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
--- !u!33 &33256649974969318
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 1038420493408916}
|
||||
m_Mesh: {fileID: 4300000, guid: 6d5af71f44006e9478341b87a6c2867b, type: 3}
|
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f78c353d457baeb44987e0ae9bc0a529
|
||||
timeCreated: 1562924724
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -52,7 +52,11 @@ namespace Passer.Tracking {
|
||||
if (_hmd != null)
|
||||
return _hmd;
|
||||
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
_hmd = FindAnyObjectByType<UnityXRHmd>();
|
||||
#else
|
||||
_hmd = FindObjectOfType<UnityXRHmd>();
|
||||
#endif
|
||||
return _hmd;
|
||||
}
|
||||
}
|
||||
@ -135,7 +139,7 @@ namespace Passer.Tracking {
|
||||
Object.DestroyImmediate(plane.gameObject);
|
||||
}
|
||||
|
||||
#endregion Hmd
|
||||
#endregion Hmd
|
||||
|
||||
#region Controller
|
||||
|
||||
@ -238,7 +242,7 @@ namespace Passer.Tracking {
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion Manage
|
||||
#endregion Manage
|
||||
|
||||
#region Init
|
||||
|
||||
|
@ -7,15 +7,17 @@ namespace Passer.Tracking {
|
||||
|
||||
public class UnityXRController : ControllerComponent {
|
||||
#if pUNITYXR
|
||||
//public TrackerComponent tracker;
|
||||
//public Transform sensorTransform {
|
||||
// get { return this.transform; }
|
||||
//}
|
||||
|
||||
protected InputDevice device;
|
||||
|
||||
protected XRNode xrNode;
|
||||
|
||||
protected enum LoadedDeviceType {
|
||||
None,
|
||||
Oculus,
|
||||
OpenXR,
|
||||
Varjo,
|
||||
}
|
||||
protected LoadedDeviceType loadedDevice = LoadedDeviceType.None;
|
||||
public GameObject model;
|
||||
|
||||
#region Manage
|
||||
@ -135,6 +137,13 @@ namespace Passer.Tracking {
|
||||
|
||||
InputDevices.deviceConnected += OnDeviceConnected;
|
||||
InputDevices.deviceDisconnected += OnDeviceDisconnected;
|
||||
|
||||
if (XRSettings.loadedDeviceName == "oculus display")
|
||||
loadedDevice = LoadedDeviceType.Oculus;
|
||||
else if (XRSettings.loadedDeviceName == "OpenXR Display")
|
||||
loadedDevice = LoadedDeviceType.OpenXR;
|
||||
else if (XRSettings.loadedDeviceName == "VarjoDisplay")
|
||||
loadedDevice = LoadedDeviceType.Varjo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -182,18 +191,24 @@ namespace Passer.Tracking {
|
||||
|
||||
status = Tracker.Status.Present;
|
||||
|
||||
Vector3 position;
|
||||
if (device.TryGetFeatureValue(CommonUsages.devicePosition, out position)) {
|
||||
transform.position = trackerTransform.TransformPoint(position);
|
||||
positionConfidence = 1;
|
||||
status = Tracker.Status.Tracking;
|
||||
}
|
||||
bool isTracked = false;
|
||||
if (device.TryGetFeatureValue(CommonUsages.isTracked, out isTracked)) {
|
||||
Vector3 position;
|
||||
if (isTracked && device.TryGetFeatureValue(CommonUsages.devicePosition, out position)) {
|
||||
transform.position = trackerTransform.TransformPoint(position);
|
||||
positionConfidence = 1;
|
||||
status = Tracker.Status.Tracking;
|
||||
}
|
||||
|
||||
Quaternion rotation;
|
||||
if (device.TryGetFeatureValue(CommonUsages.deviceRotation, out rotation)) {
|
||||
transform.rotation = trackerTransform.rotation * rotation;
|
||||
rotationConfidence = 1;
|
||||
status = Tracker.Status.Tracking;
|
||||
Quaternion rotation;
|
||||
if (isTracked && device.TryGetFeatureValue(CommonUsages.deviceRotation, out rotation)) {
|
||||
if (loadedDevice == LoadedDeviceType.OpenXR ||
|
||||
loadedDevice == LoadedDeviceType.Varjo)
|
||||
rotation *= Quaternion.AngleAxis(45, Vector3.right);
|
||||
transform.rotation = trackerTransform.rotation * rotation;
|
||||
rotationConfidence = 1;
|
||||
status = Tracker.Status.Tracking;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateInput();
|
||||
@ -249,6 +264,14 @@ namespace Passer.Tracking {
|
||||
renderers[i].enabled = showModel;
|
||||
}
|
||||
|
||||
public virtual void Vibrate(float length, float strength) {
|
||||
if (device.TryGetHapticCapabilities(out var capabilities) &&
|
||||
capabilities.supportsImpulse) {
|
||||
|
||||
device.SendHapticImpulse(0u, strength, length);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Init
|
||||
#endif
|
||||
}
|
||||
|
@ -139,6 +139,12 @@ namespace Passer.Humanoid {
|
||||
controllerInputSide.option |= controller.option > 0;
|
||||
}
|
||||
|
||||
public override void Vibrate(float length, float strength) {
|
||||
UnityXRController unityXrController = sensorComponent as UnityXRController;
|
||||
if (unityXrController != null)
|
||||
unityXrController.Vibrate(length, strength);
|
||||
}
|
||||
|
||||
// arm model for 3DOF tracking: position is calculated from rotation
|
||||
static public Vector3 CalculateHandPosition(HandTarget handTarget, Vector3 sensor2TargetPosition) {
|
||||
Quaternion hipsYRotation = Quaternion.AngleAxis(handTarget.humanoid.hipsTarget.transform.eulerAngles.y, handTarget.humanoid.up);
|
||||
|
@ -82,6 +82,17 @@ namespace Passer.Humanoid {
|
||||
return sensorComponent as UnityXRHmd;
|
||||
}
|
||||
|
||||
public void UpdateSensorLocation() {
|
||||
Vector3 position = headTarget.transform.TransformPoint(headTarget.head2eyes);
|
||||
Quaternion rotation = headTarget.transform.rotation;
|
||||
|
||||
UnityXR unityXRtracker = tracker.trackerComponent as UnityXR;
|
||||
sensorComponent = unityXRtracker.GetHmd(position, rotation);
|
||||
|
||||
sensorComponent.transform.position = position;
|
||||
sensorComponent.transform.rotation = rotation;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Start
|
||||
|
@ -357,11 +357,14 @@ namespace Passer.Humanoid {
|
||||
|
||||
#region Avatar
|
||||
|
||||
private float GetAvatarNeckHeight() {
|
||||
public event OnChangeAvatar OnChangeAvatarEvent;
|
||||
public delegate void OnChangeAvatar();
|
||||
|
||||
protected float GetAvatarNeckHeight() {
|
||||
if (avatarRig == null)
|
||||
return headTarget.transform.localPosition.y;
|
||||
|
||||
Transform avatarNeck = headTarget.neck.bone.transform; // avatarRig.GetBoneTransform(HumanBodyBones.Neck);
|
||||
Transform avatarNeck = headTarget.neck.bone.transform;
|
||||
if (avatarNeck != null) {
|
||||
float neckHeight = avatarNeck.position.y - avatarRig.transform.position.y;
|
||||
return neckHeight;
|
||||
@ -393,7 +396,7 @@ namespace Passer.Humanoid {
|
||||
}
|
||||
}
|
||||
|
||||
public void LocalChangeAvatar(GameObject avatarPrefab) {
|
||||
public virtual void LocalChangeAvatar(GameObject avatarPrefab) {
|
||||
if (avatarPrefab == null)
|
||||
return;
|
||||
|
||||
@ -450,6 +453,11 @@ namespace Passer.Humanoid {
|
||||
AddCharacterColliders();
|
||||
avatarNeckHeight = GetAvatarNeckHeight();
|
||||
|
||||
#if pUNITYXR
|
||||
if (isRemote == false && headTarget.unityXR != null)
|
||||
headTarget.unityXR.UpdateSensorLocation();
|
||||
#endif
|
||||
|
||||
switch (scaling) {
|
||||
case ScalingType.SetHeightToAvatar:
|
||||
SetTrackingHeightToAvatar();
|
||||
@ -463,9 +471,11 @@ namespace Passer.Humanoid {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
OnChangeAvatarEvent?.Invoke();
|
||||
}
|
||||
|
||||
public void InitializeAvatar() {
|
||||
public virtual void InitializeAvatar() {
|
||||
avatarRig = GetAvatar(this.gameObject);
|
||||
|
||||
// Move the animator controller to the targets rig for proper animation support
|
||||
@ -708,7 +718,7 @@ namespace Passer.Humanoid {
|
||||
rightFootTarget.MatchTargetsToAvatar();
|
||||
}
|
||||
|
||||
private void UpdateTargetsAndMovements() {
|
||||
protected void UpdateTargetsAndMovements() {
|
||||
CopyTargetsToRig();
|
||||
|
||||
UpdateTargets();
|
||||
@ -741,7 +751,7 @@ namespace Passer.Humanoid {
|
||||
}
|
||||
|
||||
/// <summary>Copies the pose of the target rig to the avatar</summary>
|
||||
private void CopyTargetsToRig() {
|
||||
public void CopyTargetsToRig() {
|
||||
hipsTarget.CopyTargetToRig();
|
||||
headTarget.CopyTargetToRig();
|
||||
leftHandTarget.CopyTargetToRig();
|
||||
@ -1085,7 +1095,7 @@ namespace Passer.Humanoid {
|
||||
}
|
||||
}
|
||||
|
||||
private TraditionalDevice traditionalInput;
|
||||
protected TraditionalDevice traditionalInput;
|
||||
|
||||
protected void InitTrackers() {
|
||||
_trackers = new HumanoidTracker[] {
|
||||
@ -1243,22 +1253,7 @@ namespace Passer.Humanoid {
|
||||
/// taller or smaller than the avatar itself.
|
||||
/// It retains 1:1 tracking and the X/Z position of the player are not affected.
|
||||
protected void SetTrackingHeightToAvatar() {
|
||||
//#if !pUNITYXR
|
||||
/*
|
||||
float localNeckHeight;
|
||||
if (headTarget.unity.cameraTransform == null ||
|
||||
UnityVRDevice.xrDevice == UnityVRDevice.XRDeviceType.None ||
|
||||
headTarget.head.target.confidence.position <= 0
|
||||
) {
|
||||
|
||||
localNeckHeight = headTarget.neck.target.transform.position.y - transform.position.y;
|
||||
}
|
||||
else {
|
||||
//Vector3 neckPosition = HeadMovements.CalculateNeckPosition(headTarget.unityVRHead.cameraTransform.position, headTarget.unityVRHead.cameraTransform.rotation, -headTarget.neck2eyes);
|
||||
//localNeckHeight = neckPosition.y - transform.position.y;
|
||||
localNeckHeight = headTarget.neck.target.transform.position.y - transform.position.y;
|
||||
}
|
||||
*/
|
||||
Vector3 neckPosition;
|
||||
if (headTarget.neck.target.confidence.position > 0.2F)
|
||||
neckPosition = headTarget.neck.target.transform.position;
|
||||
@ -1271,7 +1266,6 @@ namespace Passer.Humanoid {
|
||||
|
||||
float deltaY = avatarNeckHeight - playersNeckHeight;
|
||||
AdjustTrackingHeight(deltaY);
|
||||
//#endif
|
||||
}
|
||||
|
||||
//public void MoveTrackingHeightToAvatar() {
|
||||
@ -1322,7 +1316,7 @@ namespace Passer.Humanoid {
|
||||
|
||||
#region Update
|
||||
|
||||
protected void Update() {
|
||||
protected virtual void Update() {
|
||||
Controllers.Clear();
|
||||
UpdatePose();
|
||||
traditionalInput.UpdateGameController(gameController);
|
||||
@ -1333,7 +1327,7 @@ namespace Passer.Humanoid {
|
||||
UpdatePoseEvent();
|
||||
}
|
||||
|
||||
protected void FixedUpdate() {
|
||||
protected virtual void FixedUpdate() {
|
||||
DetermineCollision();
|
||||
CalculateMovement();
|
||||
CheckBodyPull();
|
||||
@ -1347,7 +1341,7 @@ namespace Passer.Humanoid {
|
||||
|
||||
}
|
||||
|
||||
protected void LateUpdate() {
|
||||
protected virtual void LateUpdate() {
|
||||
|
||||
PostAnimationCorrection();
|
||||
|
||||
@ -1394,15 +1388,15 @@ namespace Passer.Humanoid {
|
||||
}
|
||||
|
||||
[HideInInspector]
|
||||
private Vector3 lastHumanoidPos;
|
||||
protected Vector3 lastHumanoidPos;
|
||||
[HideInInspector]
|
||||
private float lastNeckHeight;
|
||||
protected float lastNeckHeight;
|
||||
[HideInInspector]
|
||||
private Vector3 lastHeadPosition;
|
||||
protected Vector3 lastHeadPosition;
|
||||
[HideInInspector]
|
||||
private Quaternion lastHeadRotation;
|
||||
protected Quaternion lastHeadRotation;
|
||||
[HideInInspector]
|
||||
private float lastHeadDirection;
|
||||
protected float lastHeadDirection;
|
||||
|
||||
public event OnNewNeckHeight OnNewNeckHeightEvent;
|
||||
public delegate void OnNewNeckHeight(float neckHeight);
|
||||
@ -1432,7 +1426,16 @@ namespace Passer.Humanoid {
|
||||
|
||||
#region Calibration
|
||||
|
||||
public void SetStartPosition() {
|
||||
public virtual void SetStartPosition() {
|
||||
Vector3 localNeckPosition;
|
||||
if (headTarget.neck.target.confidence.position > 0.2F)
|
||||
localNeckPosition = headTarget.neck.target.transform.position - transform.position;
|
||||
else {
|
||||
Transform headTargetTransform = headTarget.head.target.transform;
|
||||
localNeckPosition = HeadMovements.CalculateNeckPositionFromEyes(headTargetTransform.position, headTargetTransform.rotation, -headTarget.neck2eyes) - transform.position;
|
||||
}
|
||||
Vector3 delta = new Vector3(-localNeckPosition.x, 0, -localNeckPosition.z);
|
||||
AdjustTracking(delta);
|
||||
}
|
||||
|
||||
/// <summary>Calibrates the tracking with the player</summary>
|
||||
@ -1935,7 +1938,7 @@ namespace Passer.Humanoid {
|
||||
[HideInInspector]
|
||||
private readonly float colliderRadius = 0.15F;
|
||||
|
||||
private void AddCharacterColliders() {
|
||||
protected void AddCharacterColliders() {
|
||||
if (avatarRig == null || hipsTarget.hips.bone.transform == null || isRemote || !physics)
|
||||
return;
|
||||
|
||||
@ -2068,7 +2071,7 @@ namespace Passer.Humanoid {
|
||||
rightUpperLegCollider.center = new Vector3(0, -rightUpperLeg.length / 2, 0);
|
||||
}
|
||||
|
||||
private void DetermineCollision() {
|
||||
protected void DetermineCollision() {
|
||||
if (proximitySpeed) {
|
||||
//float angle = Vector3.Angle(hitNormal, targetVelocity);
|
||||
collided = (triggerEntered && bodyCapsule.radius <= 0.25f);
|
||||
@ -2080,7 +2083,7 @@ namespace Passer.Humanoid {
|
||||
hitNormal = Vector3.zero;
|
||||
}
|
||||
|
||||
public bool IsMyRigidbody(Rigidbody rigidbody) {
|
||||
public virtual bool IsMyRigidbody(Rigidbody rigidbody) {
|
||||
return
|
||||
rigidbody != null && (
|
||||
rigidbody == humanoidRigidbody ||
|
||||
@ -2137,6 +2140,8 @@ namespace Passer.Humanoid {
|
||||
/// Correct floating avatars when user is taller than the avatar
|
||||
/// </summary>
|
||||
public bool floatCorrection = false;
|
||||
public bool floatReverting = false;
|
||||
private float floatCorrectionDistance = 0.0F;
|
||||
|
||||
protected void CheckGrounded() {
|
||||
Vector3 footBase = GetHumanoidPosition();
|
||||
@ -2176,8 +2181,24 @@ namespace Passer.Humanoid {
|
||||
if (floatCorrection) {
|
||||
float leftFootBoneDistance = leftFootTarget.foot.bone.transform.position.y - leftFootTarget.foot.target.transform.position.y;
|
||||
float rightFootBoneDistance = rightFootTarget.foot.bone.transform.position.y - rightFootTarget.foot.target.transform.position.y;
|
||||
if (leftFootBoneDistance > 0.02F && rightFootBoneDistance > 0.02F)
|
||||
AdjustTrackingHeight(-0.01F);
|
||||
if (leftFootBoneDistance > 0.02F && rightFootBoneDistance > 0.02F) {
|
||||
float correction = -0.01F;
|
||||
AdjustTrackingHeight(correction);
|
||||
floatCorrectionDistance += correction;
|
||||
Debug.Log($"{floatCorrectionDistance} {leftFootBoneDistance} {rightFootBoneDistance}");
|
||||
}
|
||||
}
|
||||
if (floatReverting && floatCorrectionDistance < 0) {
|
||||
float leftFootDistance = leftFootTarget.upperLeg.bone.transform.position.y - leftFootTarget.foot.bone.transform.position.y;
|
||||
float leftBendingDistance = (leftFootTarget.upperLeg.bone.length + leftFootTarget.lowerLeg.bone.length) - leftFootDistance;
|
||||
float rightFootDistance = rightFootTarget.upperLeg.bone.transform.position.y - rightFootTarget.foot.bone.transform.position.y;
|
||||
float rightBendingDistance = (rightFootTarget.upperLeg.bone.length + rightFootTarget.lowerLeg.bone.length) - rightFootDistance;
|
||||
if (leftBendingDistance > 0.02 && rightBendingDistance > 0.02) {
|
||||
float correction = +0.01F;
|
||||
AdjustTrackingHeight(correction);
|
||||
floatCorrectionDistance += correction;
|
||||
Debug.Log($"{floatCorrectionDistance} {leftBendingDistance} {rightBendingDistance}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2298,9 +2319,9 @@ namespace Passer.Humanoid {
|
||||
#endregion
|
||||
|
||||
[HideInInspector]
|
||||
private float lastTime;
|
||||
protected float lastTime;
|
||||
|
||||
private void CalculateVelocityAcceleration() {
|
||||
protected virtual void CalculateVelocityAcceleration() {
|
||||
if (lastTime > 0) {
|
||||
float deltaTime = Time.time - lastTime;
|
||||
|
||||
|
@ -1,11 +1,9 @@
|
||||
namespace Passer.Humanoid {
|
||||
|
||||
/// \author PasserVR
|
||||
/// \version 4.0
|
||||
/// \version 4
|
||||
/// \mainpage %Humanoid Control for Unity
|
||||
///
|
||||
/// Note: this documentation is still work in progress...
|
||||
///
|
||||
/// Main components
|
||||
/// ---------------
|
||||
/// * \ref HumanoidControl "Humanoid Control"
|
||||
@ -14,12 +12,18 @@
|
||||
/// -------
|
||||
/// * \ref UnityXRTracker "UnityXR"
|
||||
/// * \ref QuestDoc "Meta Rift/Quest"
|
||||
/// * \ref LeapTracker "Ultraleap"
|
||||
/// * \ref ViveTrackerDoc "HTC Vive Trackers"
|
||||
///
|
||||
/// Input
|
||||
/// -----
|
||||
/// * ControllerInput
|
||||
/// * InteractionPointer
|
||||
///
|
||||
/// Avatars
|
||||
/// -------
|
||||
/// * Pose
|
||||
///
|
||||
/// Generic tools
|
||||
/// -------------
|
||||
/// * TeleportTarget
|
||||
@ -28,6 +32,63 @@
|
||||
///
|
||||
/// Networking
|
||||
/// ----------
|
||||
/// * \ref PhotonPunDoc "Photon PUN"
|
||||
/// * NetworkingStarter
|
||||
///
|
||||
/// Getting Started
|
||||
/// ===============
|
||||
///
|
||||
/// There are two ways to include an humanoid into a scene:
|
||||
/// starting with an avatar and starting with the Humanoid Control script.
|
||||
///
|
||||
/// Starting with an avatar
|
||||
/// -----------------------
|
||||
/// In this case you start by putting an avatar prefab into the scene.
|
||||
/// This avatar needs to fulfil the requirements of a Mecanim avatar (see below).
|
||||
/// A couple of avatar prefabs are included in the Grocery Store Demo sample in the package.
|
||||
///
|
||||
/// The next step is to attach the HumanoidControl script to the avatar.
|
||||
/// You can do this by selecting the *Add Component* button in the Inspector and selecting the HumanoidControl script.
|
||||
///
|
||||
/// \image html AddHumanoidControlComponent.png
|
||||
/// \image rtf AddHumanoidControlComponent.png
|
||||
///
|
||||
/// Starting with the Humanoid Control script
|
||||
/// -----------------------------------------
|
||||
/// In this case we start with an Empty GameObject.
|
||||
/// We will then add the HumanoidControl script to the object by selecting the *Add Component* button in the Inspector and selecting the HumanoidControl script.
|
||||
///
|
||||
/// \image html HumanoidControlWithoutAvatar.png
|
||||
/// \image rtf HumanoidControlWithoutAvatar.png
|
||||
///
|
||||
/// You will see that the script could not detect a suitable avatar because there isn't an avatar attached yet.
|
||||
/// We can now add an avatar by dropping an avatar onto the Empty GameObject we created. It will become a child of this GameObject.
|
||||
///
|
||||
/// \image html HumanoidAvatarInHierarchy.png
|
||||
/// \image rtf HumanoidAvatarInHierarchy.png
|
||||
///
|
||||
/// This makes it easier to replace an avatar at a later moment
|
||||
///
|
||||
/// Requirements for the avatar
|
||||
/// ===========================
|
||||
/// You should ensure that your avatar has a well formed rig.
|
||||
/// The script uses the bone structure derived in the Unity Mecanim rig to find the correct bones to move around.Check the rig as follows:
|
||||
/// - In the prefab, select the ‘Rig’ tab. Ensure the ‘Animation Type’ is set to ‘Humanoid’.
|
||||
/// - Ensure 'Optimize Game Objects' is *deselected*.
|
||||
/// - Click ‘Configure…’
|
||||
/// - Ensure that the following bones are correctly mapped:
|
||||
/// - Body: Hips, Spine
|
||||
/// - Left Arm: Upper Arm, Lower Arm & Hand
|
||||
/// - Right Arm: Upper Arm, Lower Arm & Hand
|
||||
/// - Left Leg: Upper Leg, Lower Leg & Foot
|
||||
/// - Right Leg: Upper Leg, Lower Leg & Foot
|
||||
/// - Head: Neck
|
||||
///
|
||||
/// If you need to grab objects with the alternative avatar you can add colliders to the hand and fingers manually.
|
||||
/// For the thumb, the intermediate joint should at least be used for a collider. For the fingers the proximal joint should at least have a collider.
|
||||
///
|
||||
/// The avatar needs to have the same size and proportions as the standard avatar. Using small or giant avatars will result in strange body moments.
|
||||
///
|
||||
/// The avatar should face in the forward direction of the root transform. Other directions will result in twisted poses.
|
||||
|
||||
}
|
||||
|
@ -32,7 +32,11 @@ namespace Passer.Humanoid {
|
||||
|
||||
inputModule = humanoid.GetComponent<InteractionModule>();
|
||||
if (inputModule == null) {
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
inputModule = Object.FindAnyObjectByType<InteractionModule>();
|
||||
#else
|
||||
inputModule = Object.FindObjectOfType<InteractionModule>();
|
||||
#endif
|
||||
if (inputModule == null) {
|
||||
inputModule = humanoid.gameObject.AddComponent<InteractionModule>();
|
||||
}
|
||||
@ -41,7 +45,7 @@ namespace Passer.Humanoid {
|
||||
inputModule.EnableTouchInput(humanoid, isLeft, 0);
|
||||
}
|
||||
|
||||
public HandSocket CreateGrabSocket() {
|
||||
public virtual HandSocket CreateGrabSocket() {
|
||||
if (hand.bone.transform == null)
|
||||
return null;
|
||||
|
||||
@ -114,7 +118,7 @@ namespace Passer.Humanoid {
|
||||
}
|
||||
}
|
||||
|
||||
private void DeterminePalmPosition() {
|
||||
protected void DeterminePalmPosition() {
|
||||
if (hand.bone.transform == null)
|
||||
return;
|
||||
|
||||
@ -658,32 +662,37 @@ namespace Passer.Humanoid {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We need to determine this here because the kinematic state
|
||||
// can change when grabbing
|
||||
grabbedKinematicRigidbody = objRigidbody.isKinematic;
|
||||
|
||||
if (objRigidbody.isKinematic)
|
||||
GrabStaticWithoutHandle(objRigidbody.gameObject);
|
||||
else
|
||||
GrabRigidbodyParenting(objRigidbody);
|
||||
|
||||
grabbedRigidbody = true;
|
||||
grabbedKinematicRigidbody = objRigidbody.isKinematic;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected virtual bool GrabRigidbodyParenting(Rigidbody objRigidbody) {
|
||||
GameObject obj = objRigidbody.gameObject;
|
||||
if (handRigidbody == null) {
|
||||
if (handRigidbody == null)
|
||||
Debug.LogError("Hand no longer has a rigidbody...");
|
||||
}
|
||||
|
||||
RigidbodyDisabled.ParentRigidbody(handRigidbody, objRigidbody);
|
||||
if (handRigidbody != null)
|
||||
handRigidbody.mass = objRigidbody.mass;
|
||||
|
||||
HumanoidNetworking.DisableNetworkSync(objRigidbody.gameObject);
|
||||
if (!humanoid.isRemote)
|
||||
HumanoidNetworking.TakeOwnership(objRigidbody.gameObject);
|
||||
|
||||
if (Application.isPlaying)
|
||||
Object.Destroy(objRigidbody);
|
||||
else
|
||||
Object.DestroyImmediate(objRigidbody, true);
|
||||
RigidbodyDisabled.ParentRigidbody(handRigidbody, objRigidbody);
|
||||
|
||||
//if (Application.isPlaying)
|
||||
// Object.Destroy(objRigidbody);
|
||||
//else
|
||||
// Object.DestroyImmediate(objRigidbody, true);
|
||||
grabbedObject = obj;
|
||||
|
||||
return true;
|
||||
@ -816,11 +825,15 @@ namespace Passer.Humanoid {
|
||||
|
||||
}
|
||||
|
||||
protected void LetGoRigidbodyWithoutHandle() {
|
||||
protected virtual void LetGoRigidbodyWithoutHandle() {
|
||||
Rigidbody objRigidbody = RigidbodyDisabled.UnparentRigidbody(handPalm, grabbedObject.transform);
|
||||
if (objRigidbody != null && !objRigidbody.isKinematic) {
|
||||
if (handRigidbody != null) {
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
objRigidbody.linearVelocity = handRigidbody.linearVelocity;
|
||||
#else
|
||||
objRigidbody.velocity = handRigidbody.velocity;
|
||||
#endif
|
||||
objRigidbody.angularVelocity = handRigidbody.angularVelocity;
|
||||
}
|
||||
HumanoidNetworking.ReenableNetworkSync(objRigidbody.gameObject);
|
||||
@ -829,11 +842,11 @@ namespace Passer.Humanoid {
|
||||
LetGoStaticWithoutHandle();
|
||||
}
|
||||
|
||||
protected void LetGoStaticWithoutHandle() {
|
||||
protected virtual void LetGoStaticWithoutHandle() {
|
||||
grabSocket.ReleaseStaticJoint();
|
||||
}
|
||||
|
||||
protected void LetGoRigidbody(Rigidbody grabbedRigidbody) {
|
||||
protected virtual void LetGoRigidbody(Rigidbody grabbedRigidbody) {
|
||||
DebugLog("LetGoRigidbody");
|
||||
|
||||
if (grabbedRigidbody != null) {
|
||||
@ -847,16 +860,24 @@ namespace Passer.Humanoid {
|
||||
}
|
||||
//grabbedRigidbody.centerOfMass = handTarget.storedCOM;
|
||||
|
||||
grabbedRigidbody.velocity = handRigidbody.velocity;
|
||||
grabbedRigidbody.angularVelocity = handRigidbody.angularVelocity;
|
||||
if (grabbedRigidbody.isKinematic == false) {
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
grabbedRigidbody.linearVelocity = handRigidbody.linearVelocity;
|
||||
#else
|
||||
grabbedRigidbody.velocity = handRigidbody.velocity;
|
||||
#endif
|
||||
grabbedRigidbody.angularVelocity = handRigidbody.angularVelocity;
|
||||
}
|
||||
|
||||
if (grabbedHandle != null)
|
||||
LetGoHandle(grabbedHandle);
|
||||
|
||||
handRigidbody.mass = 1;
|
||||
}
|
||||
this.grabbedRigidbody = false;
|
||||
}
|
||||
|
||||
protected void LetGoHandle(Handle handle) {
|
||||
protected virtual void LetGoHandle(Handle handle) {
|
||||
DebugLog("LetGoHandle " + handle);
|
||||
if (Application.isPlaying) {
|
||||
if (grabbedHandle != null) {
|
||||
|
@ -53,8 +53,13 @@ namespace Passer.Humanoid {
|
||||
handTarget.handRigidbody = handTarget.hand.bone.transform.gameObject.AddComponent<Rigidbody>();
|
||||
}
|
||||
handTarget.handRigidbody.mass = 1;
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
handTarget.handRigidbody.linearDamping = 0;
|
||||
handTarget.handRigidbody.angularDamping = 10;
|
||||
#else
|
||||
handTarget.handRigidbody.drag = 0;
|
||||
handTarget.handRigidbody.angularDrag = 10;
|
||||
#endif
|
||||
handTarget.handRigidbody.useGravity = false;
|
||||
handTarget.handRigidbody.isKinematic = true;
|
||||
handTarget.handRigidbody.interpolation = RigidbodyInterpolation.None;
|
||||
|
@ -27,13 +27,13 @@ namespace Passer.Humanoid {
|
||||
|
||||
#if hFACE
|
||||
if (headTarget.neck.target.confidence.rotation < 0.2F && headTarget.head.target.confidence.rotation < 0.2F &&
|
||||
headTarget.face.leftEye.target.confidence.rotation > 0.2F) {
|
||||
headTarget.face.leftEye.target.confidence.rotation > 0.2F && headTarget.headAnimator.headAnimation == true) {
|
||||
|
||||
UpdateHeadBonesFromGazeDirection(headTarget);
|
||||
}
|
||||
else {
|
||||
#endif
|
||||
if (Application.isPlaying && headTarget.humanoid.primaryTarget == HumanoidControl.PrimaryTarget.Hips) {
|
||||
if (Application.isPlaying && headTarget.humanoid.primaryTarget == HumanoidControl.PrimaryTarget.Hips) {
|
||||
UpdateNeckRotation(headTarget);
|
||||
UpdateNeckPositionFromHips(headTarget);
|
||||
UpdateHeadPositionFromNeck(headTarget);
|
||||
|
@ -31,7 +31,7 @@ namespace Passer.Humanoid {
|
||||
}
|
||||
}
|
||||
|
||||
private void FullInverseKinematics(FootTarget footTarget) {
|
||||
protected void FullInverseKinematics(FootTarget footTarget) {
|
||||
//Debug.Log("FullInverseKinematics");
|
||||
|
||||
if (footTarget.foot.target.transform == null)
|
||||
@ -55,7 +55,7 @@ namespace Passer.Humanoid {
|
||||
PlaceFootOnLowerLeg(footTarget, lowerLegRotation);
|
||||
}
|
||||
|
||||
private void FullForwardKinematics(FootTarget footTarget) {
|
||||
protected void FullForwardKinematics(FootTarget footTarget) {
|
||||
//Debug.Log("FullForwardKinematics");
|
||||
footTarget.upperLeg.SetBoneRotation(footTarget.upperLeg.target.transform.rotation);
|
||||
footTarget.lowerLeg.SetBoneRotation(footTarget.lowerLeg.target.transform.rotation);
|
||||
@ -82,7 +82,7 @@ namespace Passer.Humanoid {
|
||||
|
||||
#region Upper Leg
|
||||
|
||||
private Quaternion NaturalUpperLegOrientation(FootTarget footTarget, Vector3 footPosition) {
|
||||
protected Quaternion NaturalUpperLegOrientation(FootTarget footTarget, Vector3 footPosition) {
|
||||
Quaternion oldUpperLegRotation = footTarget.upperLeg.bone.transform.rotation * footTarget.upperLeg.bone.toTargetRotation;
|
||||
Quaternion upperLegRotation = CalculateUpperLegRotation(footTarget, footTarget.upperLeg.bone.transform.position, footPosition, footTarget.foot.target.transform.rotation, footTarget.upperLeg.bone.length, footTarget.lowerLeg.bone.length);
|
||||
//upperLegRotation = LimitRotationSpeed(oldUpperLegRotation, upperLegRotation);
|
||||
@ -130,7 +130,8 @@ namespace Passer.Humanoid {
|
||||
#endregion
|
||||
|
||||
#region Lower Leg
|
||||
private Quaternion NaturalLowerLegOrientation(FootTarget footTarget, Quaternion upperLegRotation, Vector3 footPosition) {
|
||||
|
||||
protected Quaternion NaturalLowerLegOrientation(FootTarget footTarget, Quaternion upperLegRotation, Vector3 footPosition) {
|
||||
float lowerLegAngle = CalculateKneeAngle(footTarget.upperLeg.bone.transform.position, footPosition, footTarget.upperLeg.bone.length, footTarget.lowerLeg.bone.length);
|
||||
|
||||
if (footTarget.lowerLeg.bone.jointLimitations)
|
||||
@ -163,12 +164,13 @@ namespace Passer.Humanoid {
|
||||
kneeAngle = 180;
|
||||
return 180 - kneeAngle;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Foot
|
||||
|
||||
// Calculate the foot position taking body limitations into account
|
||||
private Vector3 NaturalFootPosition(FootTarget footTarget) {
|
||||
protected Vector3 NaturalFootPosition(FootTarget footTarget) {
|
||||
if (footTarget.ground == null || !footTarget.physics)
|
||||
return footTarget.foot.target.transform.position;
|
||||
else {
|
||||
@ -177,7 +179,7 @@ namespace Passer.Humanoid {
|
||||
}
|
||||
|
||||
// Calculate the foot orientation taking body limitation into account
|
||||
private Quaternion NaturalFootOrientation(FootTarget footTarget) {
|
||||
protected Quaternion NaturalFootOrientation(FootTarget footTarget) {
|
||||
Quaternion footOrientation = DetermineFootOrientation(footTarget);
|
||||
if (footTarget.foot.bone.jointLimitations)
|
||||
footOrientation = LimitAngle(footTarget.foot, ref lastLocalFootRotation, footOrientation);
|
||||
@ -225,14 +227,15 @@ namespace Passer.Humanoid {
|
||||
return footPosition;
|
||||
}
|
||||
|
||||
private static void PlaceFootOnLowerLeg(FootTarget footTarget, Quaternion lowerLegRotation) {
|
||||
public static void PlaceFootOnLowerLeg(FootTarget footTarget, Quaternion lowerLegRotation) {
|
||||
footTarget.foot.bone.transform.position = footTarget.lowerLeg.bone.transform.position + lowerLegRotation * -footTarget.humanoid.up * footTarget.lowerLeg.bone.length;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Toes
|
||||
private Quaternion NaturalToesOrientation(FootTarget footTarget) {
|
||||
|
||||
protected Quaternion NaturalToesOrientation(FootTarget footTarget) {
|
||||
Quaternion footRotation = footTarget.foot.bone.transform.rotation * footTarget.foot.bone.toTargetRotation;
|
||||
if (footTarget.ground != null) {
|
||||
return Quaternion.LookRotation(footTarget.groundNormal, footRotation * Vector3.back) * Quaternion.Euler(90, 0, 0);
|
||||
@ -241,6 +244,7 @@ namespace Passer.Humanoid {
|
||||
return footRotation;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private static float Square(float x) {
|
||||
|
@ -287,7 +287,7 @@ namespace Passer.Humanoid {
|
||||
return;
|
||||
}
|
||||
#else
|
||||
if (msg.possessionLocation != null) {
|
||||
if (!string.IsNullOrEmpty(msg.possessionLocation)) {
|
||||
Debug.Log("Need to download instantiate avatar possession from " + msg.possessionLocation);
|
||||
remoteHumanoid.physics = msg.physics;
|
||||
|
||||
@ -1103,9 +1103,17 @@ namespace Passer.Humanoid {
|
||||
}
|
||||
|
||||
HumanoidTarget target = GetTarget(humanoid, targetPose.boneId);
|
||||
if (target != null)
|
||||
target.animator.enabled = false;
|
||||
//target.EnableAnimator(false);
|
||||
if (target != null) {
|
||||
if (targetPose.boneId == Tracking.Bone.Head) {
|
||||
HeadAnimator headAnimator = target.animator as HeadAnimator;
|
||||
if (headAnimator != null)
|
||||
headAnimator.headAnimation = false;
|
||||
}
|
||||
else {
|
||||
target.animator.enabled = false;
|
||||
//target.EnableAnimator(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (targetPose.boneId == Tracking.Bone.LeftHand || targetPose.boneId == Tracking.Bone.RightHand)
|
||||
ReceiveHand((HandTarget)target, (HumanoidHandPose)targetPose);
|
||||
@ -1710,7 +1718,11 @@ namespace Passer.Humanoid {
|
||||
|
||||
public static List<HumanoidControl> FindLocalHumanoids() {
|
||||
List<HumanoidControl> humanoidList = new List<HumanoidControl>();
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
HumanoidControl[] foundHumanoids = UnityEngine.Object.FindObjectsByType<HumanoidControl>(FindObjectsSortMode.None);
|
||||
#else
|
||||
HumanoidControl[] foundHumanoids = UnityEngine.Object.FindObjectsOfType<HumanoidControl>();
|
||||
#endif
|
||||
for (int i = 0; i < foundHumanoids.Length; i++) {
|
||||
if (!foundHumanoids[i].isRemote) {
|
||||
humanoidList.Add(foundHumanoids[i]);
|
||||
@ -1720,7 +1732,11 @@ namespace Passer.Humanoid {
|
||||
}
|
||||
|
||||
public static IHumanoidNetworking GetLocalHumanoidNetworking() {
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
HumanoidPlayer[] humanoidNetworkings = UnityEngine.Object.FindObjectsByType<HumanoidPlayer>(FindObjectsSortMode.None);
|
||||
#else
|
||||
HumanoidPlayer[] humanoidNetworkings = UnityEngine.Object.FindObjectsOfType<HumanoidPlayer>();
|
||||
#endif
|
||||
foreach (IHumanoidNetworking humanoidNetworking in humanoidNetworkings) {
|
||||
if (humanoidNetworking.isLocal)
|
||||
return humanoidNetworking;
|
||||
|
@ -1,7 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Passer.Humanoid {
|
||||
|
||||
public partial class HumanoidPlayerPunVoice : MonoBehaviour {
|
||||
}
|
||||
}
|
@ -6,18 +6,19 @@ namespace Passer {
|
||||
protected NetworkingStarter networkingStarter;
|
||||
protected UnityEngine.UI.Text textcomponent;
|
||||
|
||||
void Start() {
|
||||
protected void Start() {
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
networkingStarter = Object.FindAnyObjectByType<NetworkingStarter>();
|
||||
#else
|
||||
networkingStarter = FindObjectOfType<NetworkingStarter>();
|
||||
#endif
|
||||
textcomponent = GetComponent<UnityEngine.UI.Text>();
|
||||
}
|
||||
|
||||
void Update() {
|
||||
protected void Update() {
|
||||
#if hNW_UNET || hNW_PHOTON
|
||||
if (networkingStarter == null)
|
||||
return;
|
||||
|
||||
//if (textcomponent != null)
|
||||
// textcomponent.text = networkingStarter.networkingStatus.ToString();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed397d272bcc7c14eb9d4a69d7ba578f
|
||||
guid: 0abc5e15499b06b4c86e3bbbba38e130
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
@ -0,0 +1,670 @@
|
||||
#if hNW_PHOTON
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
#endif
|
||||
#if hPHOTON2
|
||||
using Photon.Realtime;
|
||||
using Photon.Pun;
|
||||
#endif
|
||||
|
||||
|
||||
namespace Passer.Humanoid {
|
||||
using Pawn;
|
||||
|
||||
#if hNW_PHOTON
|
||||
[RequireComponent(typeof(PhotonView))]
|
||||
#if hPHOTON2
|
||||
public partial class HumanoidPlayer : MonoBehaviourPunCallbacks, IHumanoidNetworking, IPunInstantiateMagicCallback, IPunObservable {
|
||||
#else
|
||||
public partial class HumanoidPlayer : Photon.MonoBehaviour, IHumanoidNetworking {
|
||||
#endif
|
||||
|
||||
public ulong nwId {
|
||||
#if hPHOTON2
|
||||
get { return (ulong)photonView.ViewID; }
|
||||
#else
|
||||
get { return (ulong)photonView.viewID; }
|
||||
#endif
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
protected float _sendRate = 25;
|
||||
public float sendRate {
|
||||
get { return _sendRate; }
|
||||
}
|
||||
|
||||
//[SerializeField]
|
||||
//protected HumanoidNetworking.DebugLevel _debug = HumanoidNetworking.DebugLevel.Error;
|
||||
//public HumanoidNetworking.DebugLevel debug {
|
||||
// get { return _debug; }
|
||||
//}
|
||||
|
||||
[SerializeField]
|
||||
protected HumanoidNetworking.Smoothing _smoothing = HumanoidNetworking.Smoothing.None;
|
||||
public HumanoidNetworking.Smoothing smoothing {
|
||||
get { return _smoothing; }
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
protected bool _createLocalRemotes = false;
|
||||
public bool createLocalRemotes {
|
||||
get { return _createLocalRemotes; }
|
||||
set { _createLocalRemotes = value; }
|
||||
}
|
||||
|
||||
public bool isLocal { get; set; }
|
||||
|
||||
public List<HumanoidControl> humanoids { get; set; }
|
||||
|
||||
public ulong GetObjectIdentity(GameObject obj) {
|
||||
PhotonView photonView = obj.GetComponent<PhotonView>();
|
||||
if (photonView == null)
|
||||
return 0;
|
||||
|
||||
#if hPHOTON2
|
||||
return (ulong)photonView.ViewID;
|
||||
#else
|
||||
return (ulong)photonView.viewID;
|
||||
#endif
|
||||
}
|
||||
|
||||
public GameObject GetGameObject(ulong objIdentity) {
|
||||
PhotonView objView = PhotonView.Find((int)objIdentity);
|
||||
if (objView == null)
|
||||
return this.gameObject;
|
||||
|
||||
return objView.gameObject;
|
||||
}
|
||||
|
||||
#region Init
|
||||
#if hPHOTON2
|
||||
public override void OnEnable() {
|
||||
base.OnEnable();
|
||||
PhotonNetwork.AddCallbackTarget(this);
|
||||
}
|
||||
|
||||
public override void OnDisable() {
|
||||
base.OnDisable();
|
||||
PhotonNetwork.RemoveCallbackTarget(this);
|
||||
}
|
||||
#endif
|
||||
public void Awake() {
|
||||
mInstance = this;
|
||||
|
||||
GameObject.DontDestroyOnLoad(this.gameObject);
|
||||
humanoids = HumanoidNetworking.FindLocalHumanoids();
|
||||
|
||||
if (debug <= HumanoidNetworking.DebugLevel.Info)
|
||||
DebugLog("Found " + humanoids.Count + " Humanoids");
|
||||
|
||||
for (int i = 0; i < humanoids.Count; i++) {
|
||||
HumanoidControl humanoid = humanoids[i];
|
||||
if (humanoid.isRemote || createLocalRemotes == false)
|
||||
continue;
|
||||
|
||||
humanoid.humanoidNetworking = this;
|
||||
((IHumanoidNetworking)this).InstantiateHumanoid(humanoid);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Start
|
||||
public void OnPhotonInstantiate(PhotonMessageInfo info) {
|
||||
#if hPHOTON2
|
||||
if (photonView.IsMine) {
|
||||
#else
|
||||
if (photonView.isMine) {
|
||||
#endif
|
||||
isLocal = true;
|
||||
name = "HumanoidPun(Local)";
|
||||
|
||||
humanoids = HumanoidNetworking.FindLocalHumanoids();
|
||||
if (debug <= HumanoidNetworking.DebugLevel.Info)
|
||||
DebugLog("Found " + humanoids.Count + " Humanoids");
|
||||
|
||||
for (int i = 0; i < humanoids.Count; i++) {
|
||||
HumanoidControl humanoid = humanoids[i];
|
||||
if (humanoid.isRemote)
|
||||
continue;
|
||||
#if hPHOTON2
|
||||
humanoid.nwId = (ulong)photonView.ViewID;
|
||||
#else
|
||||
humanoid.nwId = nwId; // photonView.viewID;
|
||||
#endif
|
||||
humanoid.humanoidNetworking = this;
|
||||
|
||||
if (debug <= HumanoidNetworking.DebugLevel.Info)
|
||||
DebugLog("Send Start Humanoid " + humanoid.humanoidId);
|
||||
|
||||
((IHumanoidNetworking)this).InstantiateHumanoid(humanoid);
|
||||
|
||||
#if hPUNVOICE2 && !UNITY_WEBGL
|
||||
InstantiatePlayerVoice(humanoid);
|
||||
#endif
|
||||
HumanoidNetworking.Connected(humanoid);
|
||||
}
|
||||
|
||||
NetworkingSpawner spawner = FindObjectOfType<NetworkingSpawner>();
|
||||
if (spawner != null)
|
||||
spawner.OnNetworkingStarted();
|
||||
|
||||
}
|
||||
else {
|
||||
humanoids = HumanoidNetworking.FindLocalHumanoids();
|
||||
if (debug <= HumanoidNetworking.DebugLevel.Info)
|
||||
DebugLog("Found " + humanoids.Count + " Humanoids");
|
||||
}
|
||||
}
|
||||
|
||||
#if hPHOTON2
|
||||
public override void OnPlayerEnteredRoom(Player newPlayer) {
|
||||
#else
|
||||
public void OnPhotonPlayerConnected(PhotonPlayer player) {
|
||||
#endif
|
||||
List<HumanoidControl> humanoids = HumanoidNetworking.FindLocalHumanoids();
|
||||
if (humanoids.Count <= 0)
|
||||
return;
|
||||
|
||||
foreach (HumanoidControl humanoid in humanoids) {
|
||||
if (debug <= HumanoidNetworking.DebugLevel.Info)
|
||||
Debug.Log(humanoid.nwId + ": (Re)Send Instantiate Humanoid " + humanoid.humanoidId);
|
||||
|
||||
// Notify new player about my humanoid
|
||||
((IHumanoidNetworking)this).InstantiateHumanoid(humanoid);
|
||||
|
||||
if (humanoid.leftHandTarget.grabbedObject != null)
|
||||
humanoid.humanoidNetworking.Grab(humanoid.leftHandTarget, humanoid.leftHandTarget.grabbedObject, false);
|
||||
if (humanoid.rightHandTarget.grabbedObject != null)
|
||||
humanoid.humanoidNetworking.Grab(humanoid.rightHandTarget, humanoid.rightHandTarget.grabbedObject, false);
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Update
|
||||
PhotonStream stream;
|
||||
|
||||
float lastSend;
|
||||
|
||||
// The number of received messages processed in this frame
|
||||
private int processedThisFrame = 0;
|
||||
private enum MessageType {
|
||||
Pose,
|
||||
Grab,
|
||||
LetGo
|
||||
}
|
||||
private struct QueuedMessage {
|
||||
public MessageType messageType;
|
||||
public byte[] data;
|
||||
}
|
||||
private Queue<QueuedMessage> messageQueue = new Queue<QueuedMessage>();
|
||||
|
||||
protected virtual void LateUpdate() {
|
||||
processedThisFrame = 0;
|
||||
if (messageQueue.Count > 0) {
|
||||
ProcessMessageFromQueue();
|
||||
Debug.Log("----Processed messages = " + messageQueue.Count);
|
||||
}
|
||||
|
||||
if (!createLocalRemotes)
|
||||
return;
|
||||
|
||||
if (Time.time > lastSend + 1 / sendRate) {
|
||||
if (humanoids != null) {
|
||||
foreach (HumanoidControl humanoid in humanoids) {
|
||||
if (!humanoid.isRemote) {
|
||||
UpdateHumanoidPose(humanoid);
|
||||
if (syncTracking)
|
||||
SyncTrackingSpace(humanoid);
|
||||
}
|
||||
}
|
||||
}
|
||||
lastSend = Time.time;
|
||||
}
|
||||
}
|
||||
|
||||
private float lastPoseTime;
|
||||
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) {
|
||||
this.stream = stream;
|
||||
#if hPHOTON2
|
||||
if (stream.IsWriting) {
|
||||
#else
|
||||
if (stream.isWriting) {
|
||||
#endif
|
||||
foreach (HumanoidControl humanoid in humanoids) {
|
||||
if (!humanoid.isRemote) {
|
||||
UpdateHumanoidPose(humanoid);
|
||||
if (syncTracking)
|
||||
SyncTrackingSpace(humanoid);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
ReceiveAvatarPose(stream);
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessMessageFromQueue() {
|
||||
QueuedMessage msg = messageQueue.Dequeue();
|
||||
switch (msg.messageType) {
|
||||
case MessageType.Pose:
|
||||
this.ReceiveHumanoidPose(msg.data);
|
||||
break;
|
||||
case MessageType.Grab:
|
||||
Debug.Log("Processing Queued Grab " + Time.time);
|
||||
this.ReceiveGrab(msg.data);
|
||||
break;
|
||||
case MessageType.LetGo:
|
||||
Debug.Log("Processsing Queueud Let Go " + Time.time);
|
||||
this.ReceiveLetGo(msg.data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Stop
|
||||
private void OnDestroy() {
|
||||
if (humanoids == null)
|
||||
return;
|
||||
|
||||
if (debug <= HumanoidNetworking.DebugLevel.Info)
|
||||
DebugLog("Destroy Remote Humanoids");
|
||||
|
||||
foreach (HumanoidControl humanoid in humanoids) {
|
||||
if (humanoid == null)
|
||||
continue;
|
||||
|
||||
if (humanoid.isRemote) {
|
||||
if (humanoid.gameObject != null)
|
||||
Destroy(humanoid.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Instantiate Humanoid
|
||||
|
||||
void IHumanoidNetworking.InstantiateHumanoid(HumanoidControl humanoid) {
|
||||
if (debug <= HumanoidNetworking.DebugLevel.Info)
|
||||
DebugLog("Send Instantiate Humanoid " + humanoid.humanoidId);
|
||||
|
||||
HumanoidNetworking.InstantiateHumanoid instantiateHumanoid = new HumanoidNetworking.InstantiateHumanoid(humanoid);
|
||||
if (createLocalRemotes) {
|
||||
this.Receive(instantiateHumanoid);
|
||||
}
|
||||
|
||||
byte[] data = instantiateHumanoid.Serialize();
|
||||
#if hPHOTON2
|
||||
photonView.RPC("RpcInstantiateHumanoid", RpcTarget.Others, data);
|
||||
#else
|
||||
photonView.RPC("RpcInstantiateHumanoid", PhotonTargets.Others, data);
|
||||
#endif
|
||||
}
|
||||
|
||||
[PunRPC]
|
||||
protected virtual void RpcInstantiateHumanoid(byte[] data) {
|
||||
this.ReceiveInstantiate(data);
|
||||
}
|
||||
|
||||
#if hPUNVOICE2 && !UNITY_WEBGL
|
||||
protected virtual void InstantiatePlayerVoice(HumanoidControl humanoid) {
|
||||
GameObject playerVoiceGameObject = PhotonNetwork.Instantiate("HumanoidPlayerVoice", humanoid.headTarget.transform.position, humanoid.headTarget.transform.rotation);
|
||||
HumanoidPlayerPunVoice playerVoice = playerVoiceGameObject.GetComponent<HumanoidPlayerPunVoice>();
|
||||
if (playerVoice != null)
|
||||
playerVoice.humanoid = humanoid;
|
||||
Debug.Log("created voice for " + humanoid);
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
|
||||
#region Destroy Humanoid
|
||||
|
||||
void IHumanoidNetworking.DestroyHumanoid(HumanoidControl humanoid) {
|
||||
if (humanoid == null)
|
||||
return;
|
||||
|
||||
if (debug <= HumanoidNetworking.DebugLevel.Info)
|
||||
DebugLog("Destroy Humanoid " + humanoid.humanoidId);
|
||||
|
||||
HumanoidNetworking.DestroyHumanoid destroyHumanoid = new HumanoidNetworking.DestroyHumanoid(humanoid);
|
||||
if (createLocalRemotes)
|
||||
this.Receive(destroyHumanoid);
|
||||
|
||||
byte[] data = destroyHumanoid.Serialize();
|
||||
#if hPHOTON2
|
||||
if (PhotonNetwork.IsConnected)
|
||||
photonView.RPC("RpcDestroyHumanoid", RpcTarget.Others, data);
|
||||
#else
|
||||
if (PhotonNetwork.connected)
|
||||
photonView.RPC("RpcDestroyHumanoid", PhotonTargets.Others, data);
|
||||
#endif
|
||||
}
|
||||
|
||||
[PunRPC]
|
||||
public void RpcDestroyHumanoid(byte[] data) {
|
||||
this.ReceiveDestroy(data);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Pose
|
||||
|
||||
public HumanoidNetworking.HumanoidPose lastHumanoidPose { get; set; }
|
||||
|
||||
public virtual void UpdateHumanoidPose(HumanoidControl humanoid) {
|
||||
if (debug <= HumanoidNetworking.DebugLevel.Debug)
|
||||
DebugLog("Send Pose Humanoid " + humanoid.humanoidId + " nwId: " + humanoid.nwId);
|
||||
|
||||
HumanoidNetworking.HumanoidPose humanoidPose = new HumanoidNetworking.HumanoidPose(humanoid, Time.time);
|
||||
if (createLocalRemotes)
|
||||
this.Receive(humanoidPose);
|
||||
|
||||
if (stream != null) {
|
||||
byte[] data = humanoidPose.Serialize();
|
||||
stream.SendNext(data);
|
||||
}
|
||||
}
|
||||
|
||||
PhotonStream reader;
|
||||
|
||||
private void ReceiveAvatarPose(PhotonStream reader) {
|
||||
this.reader = reader;
|
||||
|
||||
byte[] data = (byte[])reader.ReceiveNext();
|
||||
this.ReceiveHumanoidPose(data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Grab
|
||||
|
||||
void IHumanoidNetworking.Grab(HandTarget handTarget, GameObject obj, bool rangeCheck, HandTarget.GrabType grabType) {
|
||||
if (debug <= HumanoidNetworking.DebugLevel.Info)
|
||||
DebugLog("Grab " + obj + " " + grabType);
|
||||
|
||||
ulong objIdentity = GetObjectIdentity(obj);
|
||||
if (objIdentity == 0) {
|
||||
if (debug <= HumanoidNetworking.DebugLevel.Warning)
|
||||
Debug.LogError("Photon Grab: Grabbed object does not have a PhotonView");
|
||||
return;
|
||||
}
|
||||
|
||||
HumanoidNetworking.Grab grab = new HumanoidNetworking.Grab(handTarget, objIdentity, rangeCheck, grabType);
|
||||
if (createLocalRemotes)
|
||||
// Does this make sense?
|
||||
this.Receive(grab);
|
||||
|
||||
byte[] data = grab.Serialize();
|
||||
|
||||
#if hPHOTON2
|
||||
photonView.RPC("RpcGrab", RpcTarget.Others, data);
|
||||
#else
|
||||
photonView.RPC("RpcGrab", PhotonTargets.Others, data);
|
||||
#endif
|
||||
}
|
||||
|
||||
[PunRPC]
|
||||
public void RpcGrab(byte[] data) {
|
||||
if (processedThisFrame > 0 || messageQueue.Count > 0) {
|
||||
QueuedMessage msg = new QueuedMessage() {
|
||||
messageType = MessageType.Grab,
|
||||
data = data
|
||||
};
|
||||
messageQueue.Enqueue(msg);
|
||||
Debug.Log("++++Buffered Grab message = " + messageQueue.Count + " " + Time.time);
|
||||
return;
|
||||
}
|
||||
|
||||
this.ReceiveGrab(data);
|
||||
processedThisFrame++;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Let Go
|
||||
|
||||
void IHumanoidNetworking.LetGo(HandTarget handTarget) {
|
||||
if (debug <= HumanoidNetworking.DebugLevel.Info)
|
||||
DebugLog("LetGo");
|
||||
|
||||
HumanoidNetworking.LetGo letGo = new HumanoidNetworking.LetGo(handTarget);
|
||||
if (createLocalRemotes)
|
||||
this.Receive(letGo);
|
||||
|
||||
byte[] data = letGo.Serialize();
|
||||
#if hPHOTON2
|
||||
photonView.RPC("RpcLetGo", RpcTarget.Others, data);
|
||||
#else
|
||||
photonView.RPC("RpcLetGo", PhotonTargets.Others, data);
|
||||
#endif
|
||||
}
|
||||
|
||||
[PunRPC]
|
||||
public void RpcLetGo(byte[] data) {
|
||||
if (processedThisFrame > 0 || messageQueue.Count > 0) {
|
||||
QueuedMessage msg = new QueuedMessage() {
|
||||
messageType = MessageType.LetGo,
|
||||
data = data
|
||||
};
|
||||
messageQueue.Enqueue(msg);
|
||||
Debug.Log("++++Buffered Let Go message = " + messageQueue.Count + " " + Time.time);
|
||||
return;
|
||||
}
|
||||
|
||||
this.ReceiveLetGo(data);
|
||||
processedThisFrame++;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Change Avatar
|
||||
void IHumanoidNetworking.ChangeAvatar(HumanoidControl humanoid, string avatarPrefabName, string possessionLocation) {
|
||||
if (debug <= HumanoidNetworking.DebugLevel.Info)
|
||||
Debug.Log(humanoid.nwId + ": Change Avatar: " + avatarPrefabName);
|
||||
|
||||
HumanoidNetworking.ChangeAvatar changeAvatar = new HumanoidNetworking.ChangeAvatar(humanoid, avatarPrefabName, possessionLocation);
|
||||
if (createLocalRemotes)
|
||||
this.Receive(changeAvatar);
|
||||
|
||||
byte[] data = changeAvatar.Serialize();
|
||||
#if hPHOTON2
|
||||
photonView.RPC("RpcChangeAvatar", RpcTarget.Others, data); // humanoid.humanoidId, avatarPrefabName);
|
||||
#else
|
||||
photonView.RPC("RpcChangeAvatar", PhotonTargets.Others, data); // humanoid.humanoidId, avatarPrefabName);
|
||||
#endif
|
||||
}
|
||||
|
||||
[PunRPC]
|
||||
protected virtual void RpcChangeAvatar(byte[] data) {
|
||||
this.ReceiveChangeAvatar(data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Tracking
|
||||
|
||||
private Transform GetTrackingTransform(HumanoidControl humanoid) {
|
||||
#if hANTILATENCY
|
||||
if (humanoid.antilatency != null)
|
||||
return humanoid.antilatency.trackerTransform;
|
||||
#endif
|
||||
//#if hOPENVR && (UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX)
|
||||
// if (humanoid.openVR != null)
|
||||
// return humanoid.openVR.GetTrackingTransform();
|
||||
//#endif
|
||||
return null;
|
||||
}
|
||||
|
||||
public void SyncTrackingSpace(HumanoidControl humanoid) {
|
||||
if (humanoid == null)
|
||||
return;
|
||||
|
||||
Transform trackingTransform = GetTrackingTransform(humanoid);
|
||||
if (trackingTransform == null)
|
||||
return;
|
||||
|
||||
if (debug <= HumanoidNetworking.DebugLevel.Info)
|
||||
DebugLog("Send Sync Tracking Space " + humanoid.humanoidId + " " + trackingTransform.position + " " + trackingTransform.rotation);
|
||||
|
||||
HumanoidNetworking.SyncTrackingSpace syncTrackingSpace =
|
||||
new HumanoidNetworking.SyncTrackingSpace(humanoid, trackingTransform.position, trackingTransform.rotation);
|
||||
|
||||
if (createLocalRemotes)
|
||||
// Does this make sense?
|
||||
this.Receive(syncTrackingSpace);
|
||||
|
||||
byte[] data = syncTrackingSpace.Serialize();
|
||||
#if hPHOTON2
|
||||
photonView.RPC("RpcSyncTracking", RpcTarget.Others, data);
|
||||
#else
|
||||
photonView.RPC("RpcSyncTracking", PhotonTargets.Others, data);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
[PunRPC]
|
||||
protected virtual void RpcSyncTracking(byte[] data) {
|
||||
this.ReceiveSyncTrackingSpace(data);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Network Sync
|
||||
|
||||
void IHumanoidNetworking.ReenableNetworkSync(GameObject obj) {
|
||||
if (debug <= HumanoidNetworking.DebugLevel.Info)
|
||||
Debug.Log("ReenableNetworkSync " + obj);
|
||||
|
||||
ReenableNetworkSync(obj);
|
||||
}
|
||||
|
||||
void IHumanoidNetworking.DisableNetworkSync(GameObject obj) {
|
||||
if (debug <= HumanoidNetworking.DebugLevel.Info)
|
||||
Debug.Log("DisableNetworkSync " + obj);
|
||||
DisableNetworkSync(obj);
|
||||
}
|
||||
|
||||
public static void ReenableNetworkSync(GameObject obj) {
|
||||
#if hPHOTON2
|
||||
PhotonView photonView = obj.GetComponent<PhotonView>();
|
||||
if (photonView != null) {
|
||||
photonView.Synchronization = ViewSynchronization.UnreliableOnChange;
|
||||
}
|
||||
#endif
|
||||
|
||||
PhotonTransformView transformView = obj.GetComponent<PhotonTransformView>();
|
||||
if (transformView != null) {
|
||||
#if hPHOTON2
|
||||
transformView.m_SynchronizePosition = true;
|
||||
transformView.m_SynchronizeRotation = true;
|
||||
transformView.enabled = true;
|
||||
|
||||
#else
|
||||
transformView.m_PositionModel.SynchronizeEnabled = true;
|
||||
transformView.m_RotationModel.SynchronizeEnabled = true;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public static void TakeOwnership(GameObject obj) {
|
||||
#if hPHOTON2
|
||||
PhotonView photonView = obj.GetComponent<PhotonView>();
|
||||
if (photonView != null)
|
||||
photonView.RequestOwnership();
|
||||
#endif
|
||||
}
|
||||
|
||||
public static void DisableNetworkSync(GameObject obj) {
|
||||
PhotonTransformView transformView = obj.GetComponent<PhotonTransformView>();
|
||||
if (transformView != null) {
|
||||
#if hPHOTON2
|
||||
transformView.m_SynchronizePosition = false;
|
||||
transformView.m_SynchronizeRotation = false;
|
||||
transformView.enabled = false;
|
||||
#else
|
||||
transformView.m_PositionModel.SynchronizeEnabled = false;
|
||||
transformView.m_RotationModel.SynchronizeEnabled = false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Network Object
|
||||
|
||||
#region Void Event
|
||||
|
||||
public void RPC(FunctionCall functionCall) {
|
||||
ulong objIdentity = GetObjectIdentity(functionCall.targetGameObject);
|
||||
if (objIdentity == 0) {
|
||||
if (debug <= HumanoidNetworking.DebugLevel.Warning)
|
||||
Debug.LogError("Photon Grab: Grabbed object does not have a PhotonView");
|
||||
return;
|
||||
}
|
||||
|
||||
photonView.RPC("RpcFunctionCall", RpcTarget.Others, objIdentity, functionCall.methodName);
|
||||
}
|
||||
|
||||
[PunRPC]
|
||||
public void RpcFunctionCall(ulong objIdentity, string methodName) {
|
||||
GameObject targetGameObject = GetGameObject(objIdentity);
|
||||
if (targetGameObject == null) {
|
||||
if (debug <= HumanoidNetworking.DebugLevel.Warning)
|
||||
Debug.LogError("FunctionCall: Could not find object for method " + methodName);
|
||||
return;
|
||||
}
|
||||
|
||||
FunctionCall.Execute(targetGameObject, methodName);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion Network Object
|
||||
|
||||
#region Send
|
||||
public void Send(bool b) { stream.SendNext(b); }
|
||||
public void Send(byte b) { stream.SendNext(b); }
|
||||
public void Send(int x) { stream.SendNext(x); }
|
||||
public void Send(float f) { stream.SendNext(f); }
|
||||
public void Send(Vector3 v) { stream.SendNext(v); }
|
||||
public void Send(Quaternion q) { stream.SendNext(q); }
|
||||
#endregion
|
||||
|
||||
#region Receive
|
||||
public bool ReceiveBool() { return (bool)reader.ReceiveNext(); }
|
||||
public byte ReceiveByte() { return (byte)reader.ReceiveNext(); }
|
||||
public int ReceiveInt() { return (int)reader.ReceiveNext(); }
|
||||
public float ReceiveFloat() { return (float)reader.ReceiveNext(); }
|
||||
public Vector3 ReceiveVector3() { return (Vector3)reader.ReceiveNext(); }
|
||||
public Quaternion ReceiveQuaternion() { return (Quaternion)reader.ReceiveNext(); }
|
||||
#endregion
|
||||
|
||||
#region Debug
|
||||
|
||||
public void DebugLog(string message) {
|
||||
#if hPHOTON2
|
||||
Debug.Log(photonView.ViewID + ": " + message);
|
||||
#else
|
||||
Debug.Log(photonView.viewID + ": " + message);
|
||||
#endif
|
||||
}
|
||||
|
||||
public void DebugWarning(string message) {
|
||||
#if hPHOTON2
|
||||
Debug.LogWarning(photonView.ViewID + ": " + message);
|
||||
#else
|
||||
Debug.LogWarning(photonView.viewID + ": " + message);
|
||||
#endif
|
||||
}
|
||||
|
||||
public void DebugError(string message) {
|
||||
#if hPHOTON2
|
||||
Debug.LogError(photonView.ViewID + ": " + message);
|
||||
#else
|
||||
Debug.LogError(photonView.viewID + ": " + message);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endif
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8485b8871c8f9cf4e870d0ef4ab949cd
|
||||
timeCreated: 1483383200
|
||||
guid: b2b89683096330a4eb3810fdaeb79fb6
|
||||
timeCreated: 1504014033
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
@ -0,0 +1,72 @@
|
||||
using UnityEngine;
|
||||
#if hPUNVOICE2
|
||||
using Photon.Pun;
|
||||
#endif
|
||||
|
||||
namespace Passer.Humanoid {
|
||||
|
||||
#if !hPUNVOICE2
|
||||
public class HumanoidPlayerPunVoice : MonoBehaviour {
|
||||
#else
|
||||
public class HumanoidPlayerPunVoice : MonoBehaviourPunCallbacks {
|
||||
#endif
|
||||
/// <summary>
|
||||
/// The humanoid to follow
|
||||
/// </summary>
|
||||
public HumanoidControl humanoid;
|
||||
|
||||
#if hPUNVOICE2
|
||||
|
||||
private bool updateAudioSource = true;
|
||||
|
||||
#region Init
|
||||
|
||||
protected virtual void Start() {
|
||||
Debug.Log("Started HumanoidVoice");
|
||||
DontDestroyOnLoad(this.gameObject);
|
||||
}
|
||||
|
||||
#endregion Init
|
||||
|
||||
#region Update
|
||||
|
||||
protected virtual void Update() {
|
||||
if (photonView.Controller.IsLocal) {
|
||||
transform.position = humanoid.headTarget.transform.position;
|
||||
}
|
||||
else {
|
||||
if (updateAudioSource) {
|
||||
AudioSource audioSource = GetComponent<AudioSource>();
|
||||
if (audioSource != null) {
|
||||
audioSource.rolloffMode = AudioRolloffMode.Linear;
|
||||
audioSource.spatialBlend = 1;
|
||||
audioSource.minDistance = 0;
|
||||
audioSource.maxDistance = 1;
|
||||
updateAudioSource = false;
|
||||
}
|
||||
}
|
||||
if (humanoid == null) {
|
||||
foreach (HumanoidControl humanoid in HumanoidControl.allHumanoids) {
|
||||
if (humanoid.headTarget == null)
|
||||
continue;
|
||||
float distance = Vector3.Distance(this.transform.position, humanoid.headTarget.transform.position);
|
||||
if (distance < 0.01F) {
|
||||
this.humanoid = humanoid;
|
||||
AudioSource audioSource = this.humanoid.headTarget.GetComponentInChildren<AudioSource>();
|
||||
#if pUNITYXR
|
||||
if (audioSource == null && this.humanoid.headTarget.unityXR.unityXR.hmd != null)
|
||||
audioSource = this.humanoid.headTarget.unityXR.unityXR.hmd.GetComponentInChildren<AudioSource>();
|
||||
#endif
|
||||
if (audioSource != null)
|
||||
audioSource = this.GetComponent<AudioSource>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Update
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c48e8d9c90f89154daf3a86de9a5f2ad
|
||||
guid: 69a31162e39169c4fad112f52654bd40
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
@ -0,0 +1,64 @@
|
||||
namespace Passer.Humanoid {
|
||||
|
||||
/// \page PhotonPunDoc Photon PUN
|
||||
///
|
||||
/// Setup
|
||||
/// =====
|
||||
/// In order to use Photon PUN 2 in your project.
|
||||
/// You need to import the Photon PUN 2 package first from the asset store.
|
||||
///
|
||||
/// Networking Starter
|
||||
/// ==================
|
||||
/// When using Photon PUN 2, the Networking Starter component has the following options:
|
||||
/// \image html PhotonPunNetworkingStarter.png
|
||||
/// \image rtf PhotonPunNetworkingStarter.png
|
||||
///
|
||||
/// Networking PrefabThe player prefab which will be spawned across the network.
|
||||
/// This defaults to HumanoidPlayer for Photon Networking.Room NameThe name of the environment shared by the playersGame VersionThe version of the environment shared by the playersSend RateThe number of updates per second communicated through the network.
|
||||
///
|
||||
/// Photon Voice
|
||||
/// ============
|
||||
/// You need to include the Photon Voice 2 package in your project.
|
||||
///
|
||||
/// In the Photon Server Settings (see Window Menu->Photon Unity Networking->Highlight Server Settings,
|
||||
/// set the Settings->App Id Voice to the same App Id you use for setting up Photon 2.
|
||||
/// This App Id is also found in the App Id Realtime field.
|
||||
///
|
||||
/// Select the Photon PUN prefab which is spawned across the network.
|
||||
/// If you use the Networking Starter this usually is the HumanoidPun prefab which is found in
|
||||
/// Assets/Humanoid/Prefabs/Networking/Resources/
|
||||
/// Add the following components to the HumanoidPun prefab:
|
||||
///
|
||||
/// Add a Photon Voice View component
|
||||
///
|
||||
/// Add a Recorder component, make sure you have Auto Start and Transmit Enabled switched on
|
||||
///
|
||||
/// Set Photon Voice View->Recorder in Use to this Recorder
|
||||
///
|
||||
/// The result should look like this:
|
||||
/// \image html PhotonPunVoiceSetup.png
|
||||
/// \image rtf PhotonPunVoiceSetup.png
|
||||
///
|
||||
/// Now if you start you project, Photon Voice should work.
|
||||
///
|
||||
/// Self Hosted Networking
|
||||
/// ======================
|
||||
/// For local networking Photon PUN, go to the following page:
|
||||
/// https://www.photonengine.com/en-US/sdks#server-sdkserverserver.
|
||||
/// Then select 'Server':
|
||||
///
|
||||
/// And download the SDK.
|
||||
///
|
||||
/// Instructions on how to set it up can be found here:
|
||||
/// https://doc.photonengine.com/en-us/server/current/getting-started/photon-server-in-5min
|
||||
///
|
||||
/// The settings you need to use in Unity for Photon 2 are as follows:
|
||||
/// \image html PhotonPunSelfhosted.png
|
||||
/// \image rtf PhotonPunSelfhosted.png
|
||||
///
|
||||
/// In this case, we use a direct IP Address (localhost/127.0.01), so Use Name Server is disabled.
|
||||
/// As the protocol is Udp, you need to set port to 5055. Other port numbers can be found here:
|
||||
/// https://doc.photonengine.com/en-us/realtime/current/connection-and-authentication/tcp-and-udp-port-numbers
|
||||
/// If you start the scene now, Photon should connect to the local server.
|
||||
///
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25694d80cf4ce2940b87374eb5c2d879
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,97 @@
|
||||
using UnityEngine;
|
||||
#if hPHOTON2
|
||||
using Photon.Pun;
|
||||
using Photon.Realtime;
|
||||
#endif
|
||||
#if hPUNVOICE2
|
||||
using Photon.Voice.PUN;
|
||||
using Photon.Voice.Unity;
|
||||
#endif
|
||||
|
||||
namespace Passer {
|
||||
#if hNW_PHOTON
|
||||
public class PunStarter : INetworkingStarter {
|
||||
|
||||
public GameObject playerPrefab;
|
||||
|
||||
public string roomName;
|
||||
public int gameVersion;
|
||||
public int sendRate;
|
||||
|
||||
public void Awake() {
|
||||
#if hPUNVOICE2 && !UNITY_WEBGL
|
||||
PhotonVoiceNetwork voiceNetwork = Object.FindObjectOfType<PhotonVoiceNetwork>();
|
||||
if (voiceNetwork != null)
|
||||
return;
|
||||
|
||||
GameObject voiceNetworkObject = new GameObject("Voice Network");
|
||||
voiceNetwork = voiceNetworkObject.AddComponent<PhotonVoiceNetwork>();
|
||||
|
||||
Recorder voiceRecorder = voiceNetworkObject.AddComponent<Recorder>();
|
||||
voiceRecorder.ReactOnSystemChanges = true;
|
||||
voiceRecorder.TransmitEnabled = true;
|
||||
voiceRecorder.SamplingRate = POpusCodec.Enums.SamplingRate.Sampling48000;
|
||||
|
||||
voiceNetwork.PrimaryRecorder = voiceRecorder;
|
||||
#endif
|
||||
}
|
||||
|
||||
GameObject INetworkingStarter.GetHumanoidPrefab() {
|
||||
GameObject humanoidPrefab = Resources.Load<GameObject>("HumanoidPlayer");
|
||||
return humanoidPrefab;
|
||||
}
|
||||
|
||||
void INetworkingStarter.StartHost(NetworkingStarter nwStarter) {
|
||||
((INetworkingStarter)this).StartClient(nwStarter);
|
||||
}
|
||||
|
||||
void INetworkingStarter.StartClient(NetworkingStarter nwStarter) {
|
||||
((INetworkingStarter)this).StartClient(nwStarter, nwStarter.roomName, nwStarter.gameVersion);
|
||||
}
|
||||
|
||||
void INetworkingStarter.StartClient(NetworkingStarter nwStarter, string _roomName, int _gameVersion) {
|
||||
roomName = _roomName;
|
||||
gameVersion = _gameVersion;
|
||||
playerPrefab = Resources.Load<GameObject>("HumanoidPlayer");
|
||||
sendRate = nwStarter.sendRate;
|
||||
|
||||
#if hPHOTON2
|
||||
PhotonNetwork.SendRate = sendRate;
|
||||
PhotonNetwork.SerializationRate = sendRate;
|
||||
PhotonNetwork.GameVersion = gameVersion.ToString();
|
||||
PhotonNetwork.ConnectUsingSettings();
|
||||
#else
|
||||
PhotonNetwork.sendRate = sendRate;
|
||||
PhotonNetwork.sendRateOnSerialize = sendRate;
|
||||
PhotonNetwork.ConnectUsingSettings(gameVersion.ToString());
|
||||
#endif
|
||||
}
|
||||
|
||||
public virtual void OnConnectedToPhoton() {
|
||||
Debug.Log("Photon");
|
||||
}
|
||||
|
||||
public virtual void OnConnectedToMaster() {
|
||||
RoomOptions roomOptions = new RoomOptions() { IsVisible = false, MaxPlayers = 4 };
|
||||
PhotonNetwork.JoinOrCreateRoom(roomName, roomOptions, TypedLobby.Default);
|
||||
}
|
||||
|
||||
public virtual void OnPhotonJoinRoomFailed() {
|
||||
Debug.LogError("Could not joint the " + roomName + " room");
|
||||
}
|
||||
|
||||
public virtual void OnJoinedRoom(GameObject playerPrefab) {
|
||||
if (playerPrefab != null)
|
||||
PhotonNetwork.Instantiate(playerPrefab.name, Vector3.zero, Quaternion.identity, 0);
|
||||
|
||||
//NetworkingSpawner spawner = FindObjectOfType<NetworkingSpawner>();
|
||||
//if (spawner != null)
|
||||
// spawner.OnNetworkingStarted();
|
||||
}
|
||||
|
||||
public void StopClient() {
|
||||
PhotonNetwork.Disconnect();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bbe6fd67c1c770e478d9cb8eef19b594
|
||||
timeCreated: 1466884930
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,15 +0,0 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class FootPhysics : MonoBehaviour {
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@ namespace Passer.Humanoid {
|
||||
}
|
||||
|
||||
[HideInInspector]
|
||||
protected Rigidbody handRigidbody;
|
||||
public Rigidbody handRigidbody;
|
||||
|
||||
protected virtual void Initialize() {
|
||||
if (handTarget == null)
|
||||
@ -186,7 +186,7 @@ namespace Passer.Humanoid {
|
||||
|
||||
#region Force
|
||||
|
||||
protected Vector3 CalculateForce() {
|
||||
protected virtual Vector3 CalculateForce() {
|
||||
/*
|
||||
//Vector3 locationDifference = handTarget.stretchlessTarget.position - handTarget.handRigidbody.position;
|
||||
//Debug.DrawLine(handTarget.stretchlessTarget.position, handTarget.handRigidbody.position);
|
||||
@ -204,10 +204,17 @@ namespace Passer.Humanoid {
|
||||
return force;
|
||||
}
|
||||
|
||||
public virtual Vector3 CalculateForce(Vector3 position, Vector3 targetPosition, bool damping = false) {
|
||||
Vector3 force = (targetPosition - position) * handTarget.strength;
|
||||
if (damping)
|
||||
force += CalculateForceDamper();
|
||||
return force;
|
||||
}
|
||||
|
||||
private const float damping = 12;
|
||||
private float lastDistanceTime;
|
||||
private Vector3 lastDistanceToTarget;
|
||||
private Vector3 CalculateForceDamper() {
|
||||
protected float lastDistanceTime;
|
||||
protected Vector3 lastDistanceToTarget;
|
||||
protected virtual Vector3 CalculateForceDamper() {
|
||||
Vector3 distanceToTarget = handTarget.hand.bone.transform.position - handTarget.hand.target.transform.position;
|
||||
|
||||
float deltaTime = Time.fixedTime - lastDistanceTime;
|
||||
@ -220,7 +227,11 @@ namespace Passer.Humanoid {
|
||||
|
||||
//Compensate for absolute rigidbody speed (specifically when on a moving platform)
|
||||
if (handRigidbody != null) {
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
Vector3 residualVelocity = handRigidbody.linearVelocity - velocityTowardsTarget;
|
||||
#else
|
||||
Vector3 residualVelocity = handRigidbody.velocity - velocityTowardsTarget;
|
||||
#endif
|
||||
damper += residualVelocity * 10;
|
||||
}
|
||||
}
|
||||
@ -230,7 +241,7 @@ namespace Passer.Humanoid {
|
||||
return damper;
|
||||
}
|
||||
|
||||
protected void ApplyForce(Vector3 force) {
|
||||
protected virtual void ApplyForce(Vector3 force) {
|
||||
if (float.IsNaN(force.magnitude))
|
||||
return;
|
||||
|
||||
@ -259,7 +270,7 @@ namespace Passer.Humanoid {
|
||||
#endif
|
||||
}
|
||||
|
||||
protected void ApplyForceAtPosition(Vector3 force, Vector3 position) {
|
||||
protected virtual void ApplyForceAtPosition(Vector3 force, Vector3 position) {
|
||||
if (float.IsNaN(force.magnitude))
|
||||
return;
|
||||
|
||||
@ -273,7 +284,7 @@ namespace Passer.Humanoid {
|
||||
|
||||
#region Torque
|
||||
|
||||
protected Vector3 CalculateTorque() {
|
||||
protected virtual Vector3 CalculateTorque() {
|
||||
Quaternion sollRotation = handTarget.hand.target.transform.rotation * handTarget.hand.target.toBoneRotation;
|
||||
Quaternion istRotation = handTarget.hand.bone.transform.rotation;
|
||||
Quaternion dRot = sollRotation * Quaternion.Inverse(istRotation);
|
||||
@ -288,7 +299,7 @@ namespace Passer.Humanoid {
|
||||
return torque;
|
||||
}
|
||||
|
||||
protected Vector3 CalculateWristTorque() {
|
||||
protected virtual Vector3 CalculateWristTorque() {
|
||||
//Vector3 wristTension = target.GetWristTension();
|
||||
|
||||
// Not stable
|
||||
@ -304,7 +315,7 @@ namespace Passer.Humanoid {
|
||||
ApplyTorqueAtPosition(torque, handTarget.hand.bone.transform.position);
|
||||
}
|
||||
|
||||
protected void ApplyTorqueAtPosition(Vector3 torque, Vector3 posToApply) {
|
||||
protected virtual void ApplyTorqueAtPosition(Vector3 torque, Vector3 posToApply) {
|
||||
if (float.IsNaN(torque.magnitude))
|
||||
return;
|
||||
|
||||
@ -353,7 +364,7 @@ namespace Passer.Humanoid {
|
||||
}
|
||||
public PhysicsMode mode = PhysicsMode.HybridKinematic;
|
||||
|
||||
private bool colliding;
|
||||
protected bool colliding;
|
||||
public bool hasCollided = false;
|
||||
public Vector3 contactPoint;
|
||||
|
||||
@ -414,7 +425,7 @@ namespace Passer.Humanoid {
|
||||
colliding = false;
|
||||
}
|
||||
|
||||
public void UpdateRigidbody() {
|
||||
public virtual void UpdateRigidbody() {
|
||||
if (handRigidbody == null) {
|
||||
UpdateGrabbedMechanicalJoint();
|
||||
return;
|
||||
@ -441,7 +452,7 @@ namespace Passer.Humanoid {
|
||||
UpdateNonKinematicRigidbody();
|
||||
}
|
||||
|
||||
private void UpdateGrabbedMechanicalJoint() {
|
||||
protected void UpdateGrabbedMechanicalJoint() {
|
||||
Rigidbody grabbedRigidbody = handTarget.hand.bone.transform.GetComponentInParent<Rigidbody>();
|
||||
if (grabbedRigidbody == null)
|
||||
return;
|
||||
@ -463,7 +474,7 @@ namespace Passer.Humanoid {
|
||||
grabbedRigidbody.transform.rotation = grabbedRigidbody.transform.rotation * correctionRotation;
|
||||
}
|
||||
|
||||
private void UpdateKinematicRigidbody() {
|
||||
protected void UpdateKinematicRigidbody() {
|
||||
if (mode == PhysicsMode.NonKinematic ||
|
||||
mode == PhysicsMode.HybridKinematic && (
|
||||
handRigidbody.mass > HybridPhysics.kinematicMass ||
|
||||
@ -545,7 +556,11 @@ namespace Passer.Humanoid {
|
||||
|
||||
Vector3 velocityTarget = (positionDelta * velocityMagic) * Time.fixedDeltaTime;
|
||||
if (float.IsNaN(velocityTarget.x) == false)
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
handRigidbody.linearVelocity = Vector3.MoveTowards(handRigidbody.linearVelocity, velocityTarget, MaxVelocityChange);
|
||||
#else
|
||||
handRigidbody.velocity = Vector3.MoveTowards(handRigidbody.velocity, velocityTarget, MaxVelocityChange);
|
||||
#endif
|
||||
|
||||
rotationDelta.ToAngleAxis(out angle, out axis);
|
||||
|
||||
@ -670,7 +685,7 @@ namespace Passer.Humanoid {
|
||||
handTarget.grabbedObject.SendMessage("OnCollisionEnter", collision, SendMessageOptions.DontRequireReceiver);
|
||||
}
|
||||
|
||||
public void OnCollisionStay(Collision collision) {
|
||||
public virtual void OnCollisionStay(Collision collision) {
|
||||
if (collision.rigidbody != null && collision.rigidbody.gameObject == handTarget.grabbedObject)
|
||||
// Don't collide with the things you are holding
|
||||
return;
|
||||
|
@ -13,17 +13,17 @@ namespace Passer.Humanoid {
|
||||
/// This is the HandTarget of the hand to which the socket is attached
|
||||
public HandTarget handTarget;
|
||||
|
||||
protected override void MoveHandleToSocket(Transform socketTransform, Handle handle) {
|
||||
DebugLog("MoveHandleToHand");
|
||||
//protected override void MoveHandleToSocket(Transform socketTransform, Handle handle) {
|
||||
// DebugLog("MoveHandleToHand");
|
||||
|
||||
Transform handleTransform = handle.GetComponent<Transform>();
|
||||
Rigidbody handleRigidbody = handle.GetComponentInParent<Rigidbody>();
|
||||
if (handleRigidbody != null)
|
||||
handleTransform = handleRigidbody.transform;
|
||||
// Transform handleTransform = handle.GetComponent<Transform>();
|
||||
// Rigidbody handleRigidbody = handle.GetComponentInParent<Rigidbody>();
|
||||
// if (handleRigidbody != null)
|
||||
// handleTransform = handleRigidbody.transform;
|
||||
|
||||
handleTransform.rotation = handle.RotationTo(socketTransform.rotation) * handleTransform.rotation;
|
||||
handleTransform.position += handle.TranslationTo(socketTransform.position);
|
||||
}
|
||||
// handleTransform.rotation = handle.RotationTo(socketTransform.rotation) * handleTransform.rotation;
|
||||
// handleTransform.position += handle.TranslationTo(socketTransform.position);
|
||||
//}
|
||||
|
||||
protected override void MoveSocketToHandle(Transform socketTransform, Handle handle) {
|
||||
DebugLog("MoveHandToHandle");
|
||||
@ -155,7 +155,7 @@ namespace Passer.Humanoid {
|
||||
DestroyedJoints destroyedJoints = objRigidbody.GetComponent<DestroyedJoints>();
|
||||
|
||||
// Check if we are grabbing a hand
|
||||
BasicHandPhysics handPhysics = objRigidbody.GetComponent<BasicHandPhysics>();
|
||||
BasicHandPhysics handPhysics = objRigidbody.GetComponentInParent<BasicHandPhysics>();
|
||||
if (handPhysics != null) { // We are grabbing a hand
|
||||
if (thisRigidbody == null) {
|
||||
DebugLog("Cannot attach to hand because this handRigidbody is not present");
|
||||
|
@ -15,8 +15,13 @@ namespace Passer {
|
||||
|
||||
public RigidbodyData(Rigidbody rb) {
|
||||
mass = rb.mass;
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
drag = rb.linearDamping;
|
||||
angularDrag = rb.angularDamping;
|
||||
#else
|
||||
drag = rb.drag;
|
||||
angularDrag = rb.angularDrag;
|
||||
#endif
|
||||
useGravity = rb.useGravity;
|
||||
isKinematic = rb.isKinematic;
|
||||
interpolation = rb.interpolation;
|
||||
@ -28,8 +33,13 @@ namespace Passer {
|
||||
|
||||
public void CopyToRigidbody(Rigidbody rb) {
|
||||
rb.mass = mass;
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
rb.linearDamping = drag;
|
||||
rb.angularDamping = angularDrag;
|
||||
#else
|
||||
rb.drag = drag;
|
||||
rb.angularDrag = angularDrag;
|
||||
#endif
|
||||
rb.useGravity = useGravity;
|
||||
rb.isKinematic = isKinematic;
|
||||
rb.interpolation = interpolation;
|
||||
|
@ -40,17 +40,18 @@ namespace Passer.Humanoid {
|
||||
HumanoidTarget.TargetedBone referenceBone = humanoid.GetBone(referenceBoneRef.boneId);
|
||||
if (referenceBoneRef.boneId != Bone.None && referenceBone.target.transform != null) {
|
||||
referencePosition = referenceBone.target.transform.position;
|
||||
referenceRotation = referenceBone.bone.targetRotation;
|
||||
referenceRotation = referenceBone.target.transform.rotation; //referenceBone.bone.targetRotation;
|
||||
referenceScale = referenceBone.target.transform.lossyScale;
|
||||
}
|
||||
else {
|
||||
referencePosition = humanoid.transform.position;
|
||||
referencePosition = targetedBone.TargetBasePosition(); // humanoid.transform.position;
|
||||
referenceRotation = humanoid.transform.rotation;
|
||||
referenceScale = humanoid.transform.lossyScale;
|
||||
}
|
||||
|
||||
if (setTranslation)
|
||||
targetedBone.target.transform.position = targetedBone.TargetBasePosition() + Vector3.Lerp(Vector3.zero, referenceRotation * translation, value);
|
||||
//targetedBone.target.transform.position = targetedBone.TargetBasePosition() + Vector3.Lerp(Vector3.zero, referenceRotation * translation, value);
|
||||
targetedBone.target.transform.position = referencePosition + Vector3.Lerp(Vector3.zero, referenceRotation * translation, value);
|
||||
if (setRotation)
|
||||
targetedBone.target.transform.rotation = Quaternion.Slerp(targetedBone.TargetBaseRotation(), referenceRotation * rotation, value);
|
||||
if (setScale)
|
||||
|
@ -114,6 +114,7 @@ namespace Passer.Humanoid {
|
||||
public void ShowPose(HumanoidControl humanoid, Side showSide) {
|
||||
detectedPoseIx = -1;
|
||||
float bestScore = -1;
|
||||
detectedPose = null;
|
||||
|
||||
if (poseMode == PoseMode.Set)
|
||||
ResetAffectedBones(humanoid, showSide);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94cc904628763c548944b198ccc94346
|
||||
timeCreated: 1486644658
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
guid: 3cec17721dc9fb0499bab2210c9bf0ac
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f288e74f24dec3949aed8e4f550c4b83
|
||||
timeCreated: 1486643266
|
||||
licenseType: Free
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,9 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 02da7ec8c993b874381f34377f818316
|
||||
guid: 6abcb3631639c01478d992ecbd8dc39a
|
||||
folderAsset: yes
|
||||
timeCreated: 1486643408
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
Binary file not shown.
@ -649,7 +649,11 @@ namespace Passer.Humanoid {
|
||||
|
||||
private HumanoidControl GetHumanoid() {
|
||||
// This does not work for prefabs
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
HumanoidControl[] humanoids = FindObjectsByType<HumanoidControl>(FindObjectsSortMode.None);
|
||||
#else
|
||||
HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>();
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < humanoids.Length; i++) {
|
||||
if ((humanoids[i].leftFootTarget != null && humanoids[i].leftFootTarget.transform == this.transform) ||
|
||||
@ -829,7 +833,7 @@ namespace Passer.Humanoid {
|
||||
toes.MatchTargetToAvatar();
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Update
|
||||
|
||||
|
@ -650,7 +650,7 @@ namespace Passer.Humanoid {
|
||||
|
||||
#endregion
|
||||
|
||||
private void InitSubTargets() {
|
||||
protected void InitSubTargets() {
|
||||
//foreach (TargetedBone subTarget in subTargets)
|
||||
// subTarget.Init();
|
||||
shoulder.Init();
|
||||
@ -911,6 +911,17 @@ namespace Passer.Humanoid {
|
||||
public bool twoHandedGrab = false;
|
||||
public Vector3 targetToSecondaryHandle;
|
||||
|
||||
public bool TouchedStaticObject() {
|
||||
if (touchedObject == null)
|
||||
return false;
|
||||
|
||||
Rigidbody rb = touchedObject.GetComponent<Rigidbody>();
|
||||
if (rb == null || rb.isKinematic)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool GrabbedStaticObject() {
|
||||
if (grabbedObject != null && grabbedRigidbody && grabbedKinematicRigidbody)
|
||||
return true;
|
||||
@ -1152,7 +1163,11 @@ namespace Passer.Humanoid {
|
||||
|
||||
private HumanoidControl GetHumanoid() {
|
||||
// This does not work for prefabs
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
HumanoidControl[] humanoids = FindObjectsByType<HumanoidControl>(FindObjectsSortMode.None);
|
||||
#else
|
||||
HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>();
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < humanoids.Length; i++) {
|
||||
if ((humanoids[i].leftHandTarget != null && humanoids[i].leftHandTarget.transform == this.transform) ||
|
||||
@ -1184,8 +1199,13 @@ namespace Passer.Humanoid {
|
||||
handRigidbody = hand.bone.transform.gameObject.AddComponent<Rigidbody>();
|
||||
}
|
||||
handRigidbody.mass = 1;
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
handRigidbody.linearDamping = 0;
|
||||
handRigidbody.angularDamping = 10;
|
||||
#else
|
||||
handRigidbody.drag = 0;
|
||||
handRigidbody.angularDrag = 10;
|
||||
#endif
|
||||
handRigidbody.useGravity = false;
|
||||
handRigidbody.isKinematic = true;
|
||||
handRigidbody.interpolation = RigidbodyInterpolation.None;
|
||||
@ -1742,7 +1762,7 @@ namespace Passer.Humanoid {
|
||||
|
||||
#region Colliders
|
||||
|
||||
private void CheckColliders() {
|
||||
protected void CheckColliders() {
|
||||
if (hand.bone.transform == null)
|
||||
return;
|
||||
|
||||
|
@ -560,6 +560,7 @@ namespace Passer.Humanoid {
|
||||
neck.RetrieveBones(humanoid);
|
||||
head.RetrieveBones(humanoid);
|
||||
#if hFACE
|
||||
face.InitComponent();
|
||||
face.RetrieveBones(this);
|
||||
#endif
|
||||
}
|
||||
@ -749,7 +750,11 @@ namespace Passer.Humanoid {
|
||||
|
||||
private HumanoidControl GetHumanoid() {
|
||||
// This does not work for prefabs
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
HumanoidControl[] humanoids = FindObjectsByType<HumanoidControl>(FindObjectsSortMode.None);
|
||||
#else
|
||||
HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>();
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < humanoids.Length; i++) {
|
||||
if (humanoids[i].headTarget != null && humanoids[i].headTarget.transform == this.transform)
|
||||
@ -799,9 +804,6 @@ namespace Passer.Humanoid {
|
||||
if (humanoid == null)
|
||||
return;
|
||||
|
||||
#if hFACE
|
||||
face.InitComponent();
|
||||
#endif
|
||||
}
|
||||
|
||||
public override void StartTarget() {
|
||||
@ -878,7 +880,7 @@ namespace Passer.Humanoid {
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Update
|
||||
|
||||
@ -1064,7 +1066,7 @@ namespace Passer.Humanoid {
|
||||
#region Tools
|
||||
|
||||
/// <summary>Gets the eye position in world coordinates</summary>
|
||||
public Vector3 GetEyePosition() {
|
||||
public virtual Vector3 GetEyePosition() {
|
||||
if (Application.isPlaying && gameObject != null) {
|
||||
Camera camera = gameObject.GetComponentInChildren<Camera>();
|
||||
if (camera != null)
|
||||
@ -1220,15 +1222,6 @@ namespace Passer.Humanoid {
|
||||
}
|
||||
}
|
||||
|
||||
public void DisableVR() {
|
||||
UnityEngine.XR.XRSettings.LoadDeviceByName("None");
|
||||
}
|
||||
|
||||
public void EnableVR() {
|
||||
// Just oculus for now
|
||||
UnityEngine.XR.XRSettings.LoadDeviceByName("Oculus");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -47,6 +47,7 @@ namespace Passer.Humanoid {
|
||||
hips = new TargetedHipsBone(this);
|
||||
}
|
||||
|
||||
public bool simpleSpineIK => newSpineIK;
|
||||
public bool newSpineIK = false;
|
||||
public TorsoMovements torsoMovements = new TorsoMovements();
|
||||
|
||||
@ -88,7 +89,7 @@ namespace Passer.Humanoid {
|
||||
public CustomTorso custom = new CustomTorso();
|
||||
#endif
|
||||
|
||||
private TorsoSensor[] sensors;
|
||||
protected TorsoSensor[] sensors;
|
||||
|
||||
|
||||
public override void InitSensors() {
|
||||
@ -460,7 +461,11 @@ namespace Passer.Humanoid {
|
||||
|
||||
private HumanoidControl GetHumanoid() {
|
||||
// This does not work for prefabs
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
HumanoidControl[] humanoids = FindObjectsByType<HumanoidControl>(FindObjectsSortMode.None);
|
||||
#else
|
||||
HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>();
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < humanoids.Length; i++) {
|
||||
if (humanoids[i].hipsTarget != null && humanoids[i].hipsTarget.transform == this.transform)
|
||||
@ -614,7 +619,7 @@ namespace Passer.Humanoid {
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Update
|
||||
|
||||
|
@ -17,6 +17,7 @@ namespace Passer {
|
||||
/// </summary>
|
||||
public abstract class Target : MonoBehaviour {
|
||||
|
||||
[SerializeField]
|
||||
protected bool _showRealObjects = true;
|
||||
/// <summary>
|
||||
/// show the target meshes
|
||||
|
@ -59,7 +59,7 @@ namespace Passer.Humanoid {
|
||||
/// as the third person avatar.
|
||||
public Animator[] tpAvatars = new Animator[0];
|
||||
|
||||
private HumanoidControl humanoid;
|
||||
protected HumanoidControl humanoid;
|
||||
|
||||
protected virtual void Start() {
|
||||
humanoid = GetComponent<HumanoidControl>();
|
||||
|
@ -1,33 +1,36 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
public class FlashLight : MonoBehaviour {
|
||||
namespace Passer {
|
||||
|
||||
protected Light thisLight;
|
||||
public class FlashLight : MonoBehaviour {
|
||||
|
||||
public float duration = 0.1F;
|
||||
protected Light thisLight;
|
||||
|
||||
protected virtual void Awake() {
|
||||
thisLight = GetComponent<Light>();
|
||||
public float duration = 0.1F;
|
||||
|
||||
protected virtual void Awake() {
|
||||
thisLight = GetComponent<Light>();
|
||||
}
|
||||
|
||||
public void Flash() {
|
||||
Flash(duration);
|
||||
}
|
||||
|
||||
public void Flash(float duration) {
|
||||
if (thisLight == null)
|
||||
return;
|
||||
|
||||
StartCoroutine(FlashRoutine(thisLight, duration));
|
||||
}
|
||||
|
||||
protected IEnumerator FlashRoutine(Light light, float duration) {
|
||||
if (light == null)
|
||||
yield return null;
|
||||
|
||||
light.enabled = true;
|
||||
yield return new WaitForSeconds(duration);
|
||||
light.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Flash() {
|
||||
Flash(duration);
|
||||
}
|
||||
|
||||
public void Flash(float duration) {
|
||||
if (thisLight == null)
|
||||
return;
|
||||
|
||||
StartCoroutine(FlashRoutine(thisLight, duration));
|
||||
}
|
||||
|
||||
protected IEnumerator FlashRoutine(Light light, float duration) {
|
||||
if (light == null)
|
||||
yield return null;
|
||||
|
||||
light.enabled = true;
|
||||
yield return new WaitForSeconds(duration);
|
||||
light.enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Hit : MonoBehaviour {
|
||||
namespace Passer {
|
||||
|
||||
public void HitMe() {
|
||||
Debug.Log("AU!");
|
||||
public class Hit : MonoBehaviour {
|
||||
|
||||
public void HitMe() {
|
||||
Debug.Log("AU!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -51,7 +51,11 @@ namespace Passer {
|
||||
/// </summary>
|
||||
/// <returns>The found humanoid, null if no local humanoid has been found</returns>
|
||||
protected HumanoidControl FindHumanoid() {
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
HumanoidControl[] humanoids = FindObjectsByType<HumanoidControl>(FindObjectsSortMode.None);
|
||||
#else
|
||||
HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>();
|
||||
#endif
|
||||
for (int i = 0; i < humanoids.Length; i++) {
|
||||
if (humanoids[i].isRemote == false)
|
||||
return humanoids[i];
|
||||
|
@ -1,39 +1,47 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Redrop : MonoBehaviour {
|
||||
namespace Passer {
|
||||
|
||||
// Script which is to be replaced by CollisionEventHandler
|
||||
public class Redrop : MonoBehaviour {
|
||||
|
||||
public Collider groundCollider;
|
||||
// Script which is to be replaced by CollisionEventHandler
|
||||
|
||||
private Rigidbody thisRigidbody;
|
||||
private Vector3 startPosition;
|
||||
private Quaternion startRotation;
|
||||
public Collider groundCollider;
|
||||
|
||||
void Start() {
|
||||
startPosition = transform.position;
|
||||
startRotation = transform.rotation;
|
||||
}
|
||||
private Rigidbody thisRigidbody;
|
||||
private Vector3 startPosition;
|
||||
private Quaternion startRotation;
|
||||
|
||||
void Update() {
|
||||
if (groundCollider == null && transform.position.y < 0) {
|
||||
MoveToStart();
|
||||
protected void Start() {
|
||||
startPosition = transform.position;
|
||||
startRotation = transform.rotation;
|
||||
}
|
||||
|
||||
protected void Update() {
|
||||
if (groundCollider == null && transform.position.y < 0) {
|
||||
MoveToStart();
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnCollisionEnter(Collision collision) {
|
||||
if (collision.collider == groundCollider) {
|
||||
MoveToStart();
|
||||
}
|
||||
}
|
||||
|
||||
private void MoveToStart() {
|
||||
thisRigidbody = transform.GetComponent<Rigidbody>();
|
||||
if (thisRigidbody != null) {
|
||||
thisRigidbody.MovePosition(new Vector3(startPosition.x, startPosition.y + 0.1F, startPosition.z));
|
||||
thisRigidbody.MoveRotation(startRotation);
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
thisRigidbody.linearVelocity = Vector3.zero;
|
||||
#else
|
||||
thisRigidbody.velocity = Vector3.zero;
|
||||
#endif
|
||||
thisRigidbody.angularVelocity = Vector3.zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCollisionEnter(Collision collision) {
|
||||
if (collision.collider == groundCollider) {
|
||||
MoveToStart();
|
||||
}
|
||||
}
|
||||
|
||||
private void MoveToStart() {
|
||||
thisRigidbody = transform.GetComponent<Rigidbody>();
|
||||
if (thisRigidbody != null) {
|
||||
thisRigidbody.MovePosition(new Vector3(startPosition.x, startPosition.y + 0.1F, startPosition.z));
|
||||
thisRigidbody.MoveRotation(startRotation);
|
||||
thisRigidbody.velocity = Vector3.zero;
|
||||
thisRigidbody.angularVelocity = Vector3.zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -4,31 +4,42 @@ using UnityEngine.SceneManagement;
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
|
||||
namespace Passer {
|
||||
|
||||
[InitializeOnLoad]
|
||||
public class SceneLoader {
|
||||
static SceneLoader() {
|
||||
EditorSceneManager.sceneOpened += SceneOpened;
|
||||
}
|
||||
|
||||
private static void SceneOpened(Scene scene, OpenSceneMode mode) {
|
||||
if ((scene.name == "ObjectTable Pawn" ||
|
||||
scene.name == "ObjectTable Pawn VR" ||
|
||||
scene.name == "ObjectTable Humanoid") &&
|
||||
EditorSceneManager.loadedSceneCount == 1) {
|
||||
|
||||
//Debug.Log("Additive opening ObjectTable scene");
|
||||
EditorSceneManager.OpenScene("Assets/PawnControl/Demo/Environments/ObjectTable.unity", OpenSceneMode.Additive);
|
||||
}
|
||||
else if ((scene.name == "ShootingRange Pawn" ||
|
||||
scene.name == "ShootingRange Pawn VR" ||
|
||||
scene.name == "ShootingRange Humanoid") &&
|
||||
EditorSceneManager.loadedSceneCount == 1) {
|
||||
|
||||
//Debug.Log("Additive opening ShootingRange scene");
|
||||
EditorSceneManager.OpenScene("Assets/PawnControl/Demo/Environments/ShootingRange.unity", OpenSceneMode.Additive);
|
||||
[InitializeOnLoad]
|
||||
public class SceneLoader {
|
||||
static SceneLoader() {
|
||||
EditorSceneManager.sceneOpened += SceneOpened;
|
||||
}
|
||||
|
||||
private static void SceneOpened(Scene scene, OpenSceneMode mode) {
|
||||
if ((scene.name == "ObjectTable Pawn" ||
|
||||
scene.name == "ObjectTable Pawn VR" ||
|
||||
scene.name == "ObjectTable Humanoid")
|
||||
#if UNITY_2022_2_OR_NEWER
|
||||
&& UnityEngine.SceneManagement.SceneManager.loadedSceneCount == 1
|
||||
#else
|
||||
&& EditorSceneManager.loadedSceneCount == 1
|
||||
#endif
|
||||
) {
|
||||
//Debug.Log("Additive opening ObjectTable scene");
|
||||
EditorSceneManager.OpenScene("Assets/PawnControl/Demo/Environments/ObjectTable.unity", OpenSceneMode.Additive);
|
||||
}
|
||||
else if ((scene.name == "ShootingRange Pawn" ||
|
||||
scene.name == "ShootingRange Pawn VR" ||
|
||||
scene.name == "ShootingRange Humanoid")
|
||||
#if UNITY_2022_2_OR_NEWER
|
||||
&& UnityEngine.SceneManagement.SceneManager.loadedSceneCount == 1
|
||||
#else
|
||||
&& EditorSceneManager.loadedSceneCount == 1
|
||||
#endif
|
||||
) {
|
||||
//Debug.Log("Additive opening ShootingRange scene");
|
||||
EditorSceneManager.OpenScene("Assets/PawnControl/Demo/Environments/ShootingRange.unity", OpenSceneMode.Additive);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -1,6 +1,4 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Passer.Humanoid {
|
||||
|
||||
@ -9,8 +7,12 @@ namespace Passer.Humanoid {
|
||||
protected HandTarget handTarget;
|
||||
|
||||
protected void Start() {
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
HumanoidControl[] humanoids = FindObjectsByType<HumanoidControl>(FindObjectsSortMode.None);
|
||||
#else
|
||||
HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>();
|
||||
if (humanoids.Length != 1)
|
||||
#endif
|
||||
if (humanoids.Length != 1)
|
||||
return;
|
||||
|
||||
handTarget = isLeft ? humanoids[0].leftHandTarget : humanoids[0].rightHandTarget;
|
||||
|
@ -29,7 +29,11 @@ namespace Passer.Humanoid {
|
||||
private void Awake() {
|
||||
HumanoidControl humanoidInScene = GetComponentInParent<HumanoidControl>();
|
||||
if (humanoidInScene == null) {
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
HumanoidControl[] humanoids = FindObjectsByType<HumanoidControl>(FindObjectsSortMode.None);
|
||||
#else
|
||||
HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>();
|
||||
#endif
|
||||
foreach (HumanoidControl humanoid in humanoids) {
|
||||
if (humanoid.isRemote == false)
|
||||
this.humanoid = humanoid;
|
||||
@ -197,7 +201,7 @@ namespace Passer.Humanoid {
|
||||
SiteNavigator siteNavigator = humanoid.GetComponentInChildren<SiteNavigator>();
|
||||
siteNavigator.GoBack();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
@ -21,7 +21,11 @@ namespace Passer {
|
||||
}
|
||||
|
||||
private void OnSceneLoad(Scene scene, LoadSceneMode mode) {
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
Canvas[] canvases = FindObjectsByType<Canvas>(FindObjectsSortMode.None);
|
||||
#else
|
||||
Canvas[] canvases = FindObjectsOfType<Canvas>();
|
||||
#endif
|
||||
foreach (Canvas canvas in canvases)
|
||||
canvas.worldCamera = Camera.main;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
//namespace Passer {
|
||||
namespace Passer {
|
||||
|
||||
public static class RigidbodyTools {
|
||||
public static void DestroyGameObject(this Rigidbody rigidbody) {
|
||||
@ -8,4 +8,4 @@
|
||||
}
|
||||
}
|
||||
|
||||
//}
|
||||
}
|
@ -43,7 +43,11 @@ namespace Passer {
|
||||
#if UNITY_EDITOR
|
||||
UnityEngine.SceneManagement.SceneManager.sceneLoaded += OnSceneLoad;
|
||||
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
HumanoidControl humanoid = FindAnyObjectByType<HumanoidControl>();
|
||||
#else
|
||||
HumanoidControl humanoid = FindObjectOfType<HumanoidControl>();
|
||||
#endif
|
||||
if (humanoid == null) {
|
||||
string visitorScenePath = HumanoidPreferences.visitorSceneName;
|
||||
if (!string.IsNullOrEmpty(visitorScenePath)) {
|
||||
@ -57,17 +61,29 @@ namespace Passer {
|
||||
|
||||
private void OnSceneLoad(Scene _, LoadSceneMode _1) {
|
||||
#if UNITY_EDITOR
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
SiteNavigator[] siteNavigators = FindObjectsByType<SiteNavigator>(FindObjectsSortMode.None);
|
||||
#else
|
||||
SiteNavigator[] siteNavigators = FindObjectsOfType<SiteNavigator>();
|
||||
#endif
|
||||
foreach (SiteNavigator siteNavigator in siteNavigators) {
|
||||
siteNavigator.startScene = null;
|
||||
siteNavigator.startSite = null;
|
||||
}
|
||||
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
HumanoidControl pawn = FindAnyObjectByType<HumanoidControl>();
|
||||
#else
|
||||
HumanoidControl pawn = FindObjectOfType<HumanoidControl>();
|
||||
#endif
|
||||
if (pawn == null)
|
||||
return;
|
||||
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
HumanoidSpawnPoint[] spawnPoints = FindObjectsByType<HumanoidSpawnPoint>(FindObjectsSortMode.None);
|
||||
#else
|
||||
HumanoidSpawnPoint[] spawnPoints = FindObjectsOfType<HumanoidSpawnPoint>();
|
||||
#endif
|
||||
foreach (HumanoidSpawnPoint spawnPoint in spawnPoints) {
|
||||
if (spawnPoint.isFree)
|
||||
pawn.transform.position = spawnPoint.transform.position;
|
||||
|
@ -87,7 +87,7 @@ namespace Passer {
|
||||
UnityEditor.SceneManagement.EditorSceneManager.LoadSceneInPlayMode(startScene, new LoadSceneParameters(LoadSceneMode.Additive));
|
||||
currentSite = new HistoryEntry() {
|
||||
siteName = "directload",
|
||||
siteLocation = "passervr.com/sites/start",
|
||||
siteLocation = "serrarens.nl/sites/start",
|
||||
scenePath = "",
|
||||
assetBundle = currentAssetBundle,
|
||||
};
|
||||
@ -248,7 +248,7 @@ namespace Passer {
|
||||
|
||||
UnityEngine.UI.Text text = dialogObj.AddComponent<UnityEngine.UI.Text>();
|
||||
text.text = dialogText;
|
||||
text.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
|
||||
text.font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
|
||||
text.resizeTextForBestFit = true;
|
||||
text.alignment = TextAnchor.MiddleCenter;
|
||||
|
||||
|
@ -16,8 +16,12 @@ namespace Passer {
|
||||
|
||||
UnityEngine.SceneManagement.SceneManager.sceneLoaded += OnSceneLoad;
|
||||
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
HumanoidControl pawn = FindAnyObjectByType<HumanoidControl>();
|
||||
#else
|
||||
HumanoidControl pawn = FindObjectOfType<HumanoidControl>();
|
||||
if (pawn == null) {
|
||||
#endif
|
||||
if (pawn == null) {
|
||||
UnityEngine.SceneManagement.SceneManager.LoadScene(sceneName);
|
||||
}
|
||||
DontDestroyOnLoad(this.gameObject);
|
||||
@ -26,8 +30,12 @@ namespace Passer {
|
||||
|
||||
private void OnSceneLoad(UnityEngine.SceneManagement.Scene _, LoadSceneMode _1) {
|
||||
#if UNITY_EDITOR
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
SiteNavigator siteNavigator = FindAnyObjectByType<SiteNavigator>();
|
||||
#else
|
||||
SiteNavigator siteNavigator = FindObjectOfType<SiteNavigator>();
|
||||
if (siteNavigator != null) {
|
||||
#endif
|
||||
if (siteNavigator != null) {
|
||||
siteNavigator.startScene = thisSceneName;
|
||||
}
|
||||
#endif
|
||||
|
@ -1,66 +1,68 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
using Passer;
|
||||
namespace Passer {
|
||||
|
||||
public class ControllerDebugger : MonoBehaviour {
|
||||
public class ControllerDebugger : MonoBehaviour {
|
||||
|
||||
[System.Serializable]
|
||||
public struct ControllerSideDebugger {
|
||||
public float stickHorizontal;
|
||||
public float stickVertical;
|
||||
public bool stickButton;
|
||||
public bool stickTouch;
|
||||
[System.Serializable]
|
||||
public struct ControllerSideDebugger {
|
||||
public float stickHorizontal;
|
||||
public float stickVertical;
|
||||
public bool stickButton;
|
||||
public bool stickTouch;
|
||||
|
||||
public float touchpadHorizontal;
|
||||
public float touchpadVertical;
|
||||
public bool touchpadButton;
|
||||
public bool touchpadTouch;
|
||||
public float touchpadHorizontal;
|
||||
public float touchpadVertical;
|
||||
public bool touchpadButton;
|
||||
public bool touchpadTouch;
|
||||
|
||||
public bool[] buttons;
|
||||
public bool[] buttons;
|
||||
|
||||
public float bumper;
|
||||
public float trigger;
|
||||
public float bumper;
|
||||
public float trigger;
|
||||
|
||||
public bool option;
|
||||
public bool option;
|
||||
}
|
||||
|
||||
public ControllerSideDebugger left;
|
||||
public ControllerSideDebugger right;
|
||||
|
||||
private Controller controller;
|
||||
|
||||
private void Start() {
|
||||
controller = Controllers.GetController(0);
|
||||
|
||||
left.buttons = new bool[4];
|
||||
right.buttons = new bool[4];
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
UpdateSide(ref left, controller.left);
|
||||
UpdateSide(ref right, controller.right);
|
||||
}
|
||||
|
||||
void UpdateSide(ref ControllerSideDebugger sideDebugger, ControllerSide controllerSide) {
|
||||
sideDebugger.stickHorizontal = controllerSide.stickHorizontal;
|
||||
sideDebugger.stickVertical = controllerSide.stickVertical;
|
||||
sideDebugger.stickButton = controllerSide.stickButton;
|
||||
sideDebugger.stickTouch = controllerSide.stickTouch;
|
||||
|
||||
sideDebugger.touchpadHorizontal = controllerSide.touchpadHorizontal;
|
||||
sideDebugger.touchpadVertical = controllerSide.touchpadVertical;
|
||||
sideDebugger.touchpadButton = controllerSide.touchpadPress;
|
||||
sideDebugger.touchpadTouch = controllerSide.touchpadTouch;
|
||||
|
||||
sideDebugger.buttons[0] = controllerSide.buttons[0];
|
||||
sideDebugger.buttons[1] = controllerSide.buttons[1];
|
||||
sideDebugger.buttons[2] = controllerSide.buttons[2];
|
||||
sideDebugger.buttons[3] = controllerSide.buttons[3];
|
||||
|
||||
sideDebugger.bumper = controllerSide.trigger1;
|
||||
sideDebugger.trigger = controllerSide.trigger2;
|
||||
|
||||
sideDebugger.option = controllerSide.option;
|
||||
}
|
||||
}
|
||||
|
||||
public ControllerSideDebugger left;
|
||||
public ControllerSideDebugger right;
|
||||
|
||||
private Controller controller;
|
||||
|
||||
private void Start () {
|
||||
controller = Controllers.GetController(0);
|
||||
|
||||
left.buttons = new bool[4];
|
||||
right.buttons = new bool[4];
|
||||
}
|
||||
|
||||
private void Update () {
|
||||
UpdateSide(ref left, controller.left);
|
||||
UpdateSide(ref right, controller.right);
|
||||
}
|
||||
|
||||
void UpdateSide(ref ControllerSideDebugger sideDebugger, ControllerSide controllerSide) {
|
||||
sideDebugger.stickHorizontal = controllerSide.stickHorizontal;
|
||||
sideDebugger.stickVertical = controllerSide.stickVertical;
|
||||
sideDebugger.stickButton = controllerSide.stickButton;
|
||||
sideDebugger.stickTouch = controllerSide.stickTouch;
|
||||
|
||||
sideDebugger.touchpadHorizontal = controllerSide.touchpadHorizontal;
|
||||
sideDebugger.touchpadVertical = controllerSide.touchpadVertical;
|
||||
sideDebugger.touchpadButton = controllerSide.touchpadPress;
|
||||
sideDebugger.touchpadTouch = controllerSide.touchpadTouch;
|
||||
|
||||
sideDebugger.buttons[0] = controllerSide.buttons[0];
|
||||
sideDebugger.buttons[1] = controllerSide.buttons[1];
|
||||
sideDebugger.buttons[2] = controllerSide.buttons[2];
|
||||
sideDebugger.buttons[3] = controllerSide.buttons[3];
|
||||
|
||||
sideDebugger.bumper = controllerSide.trigger1;
|
||||
sideDebugger.trigger = controllerSide.trigger2;
|
||||
|
||||
sideDebugger.option = controllerSide.option;
|
||||
}
|
||||
}
|
||||
}
|
@ -62,9 +62,11 @@ namespace Passer {
|
||||
|
||||
public float leftStickVertical { get { return controller.left.stickVertical; } }
|
||||
public float leftStickHorizontal { get { return controller.left.stickHorizontal; } }
|
||||
public bool leftStickPressed { get { return controller.left.stickButton; } }
|
||||
|
||||
public float leftTouchpadVertical { get { return controller.left.touchpadVertical; } }
|
||||
public float leftTouchpadHorizontal { get { return controller.left.touchpadHorizontal; } }
|
||||
public bool leftTouchpadPressed { get { return controller.left.touchpadPress; } }
|
||||
|
||||
public float leftTrigger1 { get { return controller.left.trigger1; } }
|
||||
public bool leftTrigger1Touched { get { return controller.left.trigger1 > 0; } }
|
||||
@ -81,9 +83,11 @@ namespace Passer {
|
||||
|
||||
public float rightStickVertical { get { return controller.right.stickVertical; } }
|
||||
public float rightStickHorizontal { get { return controller.right.stickHorizontal; } }
|
||||
public bool rightStickPressed { get { return controller.right.stickButton; } }
|
||||
|
||||
public float rightTouchpadVertical { get { return controller.right.touchpadVertical; } }
|
||||
public float rightTouchpadHorizontal { get { return controller.right.touchpadHorizontal; } }
|
||||
public bool rightTouchpadPressed { get { return controller.right.touchpadPress; } }
|
||||
|
||||
public float rightTrigger1 { get { return controller.right.trigger1; } }
|
||||
public bool rightTrigger1Touched { get { return controller.right.trigger1 > 0; } }
|
||||
|
@ -90,7 +90,7 @@ namespace Passer {
|
||||
}
|
||||
|
||||
virtual protected void UpdateKinematicRigidbody() {
|
||||
if (mode == PhysicsMode.NonKinematic ||
|
||||
if (mode == PhysicsMode.NonKinematic ||
|
||||
thisRigidbody.mass > kinematicMass ||
|
||||
thisRigidbody.GetComponent<Joint>() != null
|
||||
) {
|
||||
@ -183,7 +183,7 @@ namespace Passer {
|
||||
// The sweeptests fail quite often...
|
||||
//RaycastHit hit;
|
||||
//if (!thisRigidbody.SweepTest(target.transform.position - thisRigidbody.position, out hit))
|
||||
hasCollided = false;
|
||||
hasCollided = false;
|
||||
|
||||
}
|
||||
}
|
||||
@ -229,7 +229,11 @@ namespace Passer {
|
||||
damper = -velocityTowardsTarget * damping;
|
||||
|
||||
//Compensate for absolute rigidbody speed (specifically when on a moving platform)
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
Vector3 residualVelocity = thisRigidbody.linearVelocity - velocityTowardsTarget;
|
||||
#else
|
||||
Vector3 residualVelocity = thisRigidbody.velocity - velocityTowardsTarget;
|
||||
#endif
|
||||
damper += residualVelocity * 10;
|
||||
}
|
||||
lastDistanceToTarget = distanceToTarget;
|
||||
@ -320,7 +324,34 @@ namespace Passer {
|
||||
Vector3 tmp = Vector3.Cross(a, b).normalized;
|
||||
return tmp;
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Rotates a rigibogy to the desired rotation.
|
||||
/// See: https://digitalopus.ca/site/pd-controllers/
|
||||
/// </summary>
|
||||
/// <param name="rb">The rigidbody to rotate</param>
|
||||
/// <param name="desiredRotation">The orientation which is desired</param>
|
||||
/// <param name="frequency">The speed to reach the desired rotation, duration is approximate 1/frequency</param>
|
||||
/// <param name="damping">1 = critical damped, < 1 under damped, > 1 over damped </param>
|
||||
public static void ApplyTorqueBackwardsPD(Rigidbody rb, Quaternion desiredRotation, float frequency = 1, float damping = 1) {
|
||||
float kp = (6f * frequency) * (6f * frequency) * 0.25f;
|
||||
float kd = 4.5f * frequency * damping;
|
||||
|
||||
Vector3 x;
|
||||
float xMag;
|
||||
Quaternion q = desiredRotation * Quaternion.Inverse(rb.transform.rotation);
|
||||
q.ToAngleAxis(out xMag, out x);
|
||||
x.Normalize();
|
||||
x *= Mathf.Deg2Rad;
|
||||
Vector3 pidv = kp * x * xMag - kd * rb.angularVelocity;
|
||||
Quaternion rotInertia2World = rb.inertiaTensorRotation * rb.transform.rotation;
|
||||
pidv = Quaternion.Inverse(rotInertia2World) * pidv;
|
||||
pidv.Scale(rb.inertiaTensor);
|
||||
pidv = rotInertia2World * pidv;
|
||||
rb.AddTorque(pidv);
|
||||
}
|
||||
|
||||
#endregion Torque
|
||||
|
||||
#region Utilities
|
||||
|
||||
@ -382,6 +413,14 @@ namespace Passer {
|
||||
UnsetCollidersToTrigger(colliders);
|
||||
}
|
||||
|
||||
public static void SetNonKinematic(Rigidbody rigidbody, List<Collider> colliders) {
|
||||
if (rigidbody == null)
|
||||
return;
|
||||
|
||||
rigidbody.isKinematic = false;
|
||||
UnsetCollidersToTrigger(colliders);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Switches this Rigidbody to Hybrid Kinematic Mode
|
||||
/// </summary>
|
||||
@ -426,6 +465,16 @@ namespace Passer {
|
||||
return changedColliders;
|
||||
}
|
||||
|
||||
public static List<Collider> SetKinematic(Rigidbody rigidbody) {
|
||||
if (rigidbody == null)
|
||||
return new List<Collider>();
|
||||
|
||||
rigidbody.isKinematic = true;
|
||||
Collider[] colliders = rigidbody.GetComponentsInChildren<Collider>();
|
||||
List<Collider> changedColliders = SetCollidersToTrigger(rigidbody, colliders);
|
||||
return changedColliders;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Colliders
|
||||
@ -536,8 +585,10 @@ namespace Passer {
|
||||
if (colliders == null)
|
||||
return;
|
||||
|
||||
foreach (Collider c in colliders)
|
||||
c.isTrigger = false;
|
||||
foreach (Collider c in colliders) {
|
||||
if (c != null)
|
||||
c.isTrigger = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -552,8 +603,10 @@ namespace Passer {
|
||||
if (colliders == null)
|
||||
return;
|
||||
|
||||
foreach (Collider c in colliders)
|
||||
c.isTrigger = false;
|
||||
foreach (Collider c in colliders) {
|
||||
if (c != null)
|
||||
c.isTrigger = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -30,8 +30,13 @@ namespace Passer {
|
||||
|
||||
public void CopyFromRigidbody(Rigidbody rb) {
|
||||
mass = rb.mass;
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
drag = rb.linearDamping;
|
||||
angularDrag = rb.angularDamping;
|
||||
#else
|
||||
drag = rb.drag;
|
||||
angularDrag = rb.angularDrag;
|
||||
#endif
|
||||
useGravity = rb.useGravity;
|
||||
isKinematic = rb.isKinematic;
|
||||
interpolation = rb.interpolation;
|
||||
@ -44,8 +49,13 @@ namespace Passer {
|
||||
|
||||
public void CopyToRigidbody(Rigidbody rb) {
|
||||
rb.mass = mass;
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
rb.linearDamping = drag;
|
||||
rb.angularDamping = angularDrag;
|
||||
#else
|
||||
rb.drag = drag;
|
||||
rb.angularDrag = angularDrag;
|
||||
#endif
|
||||
rb.useGravity = useGravity;
|
||||
rb.isKinematic = isKinematic;
|
||||
rb.interpolation = interpolation;
|
||||
|
@ -78,6 +78,38 @@ namespace Passer {
|
||||
|
||||
return newRotation1;
|
||||
}
|
||||
|
||||
public static void ToSwingTwist(this Quaternion q, Vector3 twistAxis, out Quaternion swing, out Quaternion twist) {
|
||||
Vector3 r = new Vector3(q.x, q.y, q.z);
|
||||
|
||||
// singularity: rotation by 180 degree
|
||||
if (r.sqrMagnitude < Mathf.Epsilon) {
|
||||
Vector3 rotatedTwistAxis = q * twistAxis;
|
||||
Vector3 swingAxis =
|
||||
Vector3.Cross(twistAxis, rotatedTwistAxis);
|
||||
|
||||
if (swingAxis.sqrMagnitude > Mathf.Epsilon) {
|
||||
float swingAngle =
|
||||
Vector3.Angle(twistAxis, rotatedTwistAxis);
|
||||
swing = Quaternion.AngleAxis(swingAngle, swingAxis);
|
||||
}
|
||||
else {
|
||||
// more singularity:
|
||||
// rotation axis parallel to twist axis
|
||||
swing = Quaternion.identity; // no swing
|
||||
}
|
||||
|
||||
// always twist 180 degree on singularity
|
||||
twist = Quaternion.AngleAxis(180.0f, twistAxis);
|
||||
return;
|
||||
}
|
||||
|
||||
// meat of swing-twist decomposition
|
||||
Vector3 p = Vector3.Project(r, twistAxis);
|
||||
twist = new Quaternion(p.x, p.y, p.z, q.w);
|
||||
twist = Quaternion.Normalize(twist);
|
||||
swing = q * Quaternion.Inverse(twist);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Vectors {
|
||||
@ -110,93 +142,4 @@ namespace Passer {
|
||||
}
|
||||
}
|
||||
|
||||
//public class RigidbodyData {
|
||||
// public float mass = 1;
|
||||
// public float drag;
|
||||
// public float angularDrag = 0.05F;
|
||||
// public bool useGravity = true;
|
||||
// public bool isKinematic;
|
||||
// public RigidbodyInterpolation interpolation = RigidbodyInterpolation.None;
|
||||
// public CollisionDetectionMode collisionDetectionMode = CollisionDetectionMode.Discrete;
|
||||
// public RigidbodyConstraints constraints = RigidbodyConstraints.None;
|
||||
// public Transform parent;
|
||||
|
||||
// public RigidbodyData(Rigidbody rb) {
|
||||
// mass = rb.mass;
|
||||
// drag = rb.drag;
|
||||
// angularDrag = rb.angularDrag;
|
||||
// useGravity = rb.useGravity;
|
||||
// isKinematic = rb.isKinematic;
|
||||
// interpolation = rb.interpolation;
|
||||
// collisionDetectionMode = rb.collisionDetectionMode;
|
||||
// constraints = rb.constraints;
|
||||
|
||||
// parent = rb.transform.parent;
|
||||
// }
|
||||
|
||||
// public void CopyToRigidbody(Rigidbody rb) {
|
||||
// rb.mass = mass;
|
||||
// rb.drag = drag;
|
||||
// rb.angularDrag = angularDrag;
|
||||
// rb.useGravity = useGravity;
|
||||
// rb.isKinematic = isKinematic;
|
||||
// rb.interpolation = interpolation;
|
||||
// rb.collisionDetectionMode = collisionDetectionMode;
|
||||
// rb.constraints = constraints;
|
||||
|
||||
// rb.transform.parent = parent;
|
||||
// }
|
||||
|
||||
// public static RigidbodyData ParentRigidbody(Transform parentTransform, Rigidbody childRigidbody) {
|
||||
// RigidbodyData rigidbodyData = new RigidbodyData(childRigidbody);
|
||||
|
||||
// childRigidbody.transform.parent = parentTransform;
|
||||
|
||||
// if (Application.isPlaying)
|
||||
// Object.Destroy(childRigidbody);
|
||||
// else
|
||||
// Object.DestroyImmediate(childRigidbody, true);
|
||||
|
||||
// return rigidbodyData;
|
||||
// }
|
||||
|
||||
// public static RigidbodyData ParentRigidbody(Rigidbody parentRigidbody, Rigidbody childRigidbody) {
|
||||
// RigidbodyData rigidbodyData = new RigidbodyData(childRigidbody);
|
||||
|
||||
// childRigidbody.transform.parent = parentRigidbody.transform;
|
||||
// parentRigidbody.mass += childRigidbody.mass;
|
||||
|
||||
// if (Application.isPlaying)
|
||||
// Object.Destroy(childRigidbody);
|
||||
// else
|
||||
// Object.DestroyImmediate(childRigidbody, true);
|
||||
|
||||
// return rigidbodyData;
|
||||
// }
|
||||
|
||||
// public Rigidbody UnparentRigidbody(Transform parentTransform, Transform childRigidbodyTransform) {
|
||||
// Rigidbody childRigidbody = childRigidbodyTransform.GetComponent<Rigidbody>();
|
||||
// if (!childRigidbodyTransform.gameObject.isStatic && childRigidbody == null) {
|
||||
// childRigidbody = childRigidbodyTransform.gameObject.AddComponent<Rigidbody>();
|
||||
// CopyToRigidbody(childRigidbody);
|
||||
// }
|
||||
// childRigidbody.transform.parent = null;
|
||||
|
||||
// // To do: copy velocity of parent to child
|
||||
// return childRigidbody;
|
||||
// }
|
||||
|
||||
// public Rigidbody UnparentRigidbody(Rigidbody parentRigidbody, Transform childRigidbodyTransform) {
|
||||
// Rigidbody childRigidbody = childRigidbodyTransform.GetComponent<Rigidbody>();
|
||||
// if (!childRigidbodyTransform.gameObject.isStatic && childRigidbody == null) {
|
||||
// childRigidbody = childRigidbodyTransform.gameObject.AddComponent<Rigidbody>();
|
||||
// CopyToRigidbody(childRigidbody);
|
||||
// }
|
||||
// parentRigidbody.mass -= childRigidbody.mass;
|
||||
|
||||
// // To do: copy velocity of parent to child
|
||||
// return childRigidbody;
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
@ -46,13 +46,17 @@ namespace Passer.Humanoid {
|
||||
}
|
||||
}
|
||||
|
||||
private void Awake() {
|
||||
protected void Awake() {
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
HumanoidControl humanoid = Object.FindAnyObjectByType<HumanoidControl>();
|
||||
#else
|
||||
HumanoidControl humanoid = FindObjectOfType<HumanoidControl>();
|
||||
#endif
|
||||
if (humanoid == null)
|
||||
return;
|
||||
|
||||
Vector3 humanoidXZ = new Vector3(humanoid.transform.position.x, 0, humanoid.transform.position.z);
|
||||
Vector3 thisXZ = new Vector3(this.transform.position.x, 0, this.transform.position.z);
|
||||
Vector3 humanoidXZ = new(humanoid.transform.position.x, 0, humanoid.transform.position.z);
|
||||
Vector3 thisXZ = new(this.transform.position.x, 0, this.transform.position.z);
|
||||
float distance = Vector3.Distance(humanoidXZ, thisXZ);
|
||||
if (distance < radius || isFree)
|
||||
humanoid.transform.MoveTo(this.transform.position);
|
||||
@ -103,6 +107,6 @@ namespace Passer.Humanoid {
|
||||
Gizmos.DrawLine(pos, lastPos);
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ namespace Passer {
|
||||
// This is not working, because Unity may set this to the wrong object autonomously
|
||||
//touchedObject = data.pointerCurrentRaycast.gameObject;
|
||||
//if (touchedObject == null) {// object is a 3D object, as we do not use Physicsraycaster, use the focusObject
|
||||
touchedObject = focusObject;
|
||||
touchedObject = focusObject;
|
||||
//}
|
||||
DebugLog("Touch " + touchedObject);
|
||||
|
||||
@ -121,8 +121,10 @@ namespace Passer {
|
||||
|
||||
focusing = true;
|
||||
return;
|
||||
|
||||
}
|
||||
else
|
||||
ProcessFocus();
|
||||
|
||||
if (!clicking) { // first activation
|
||||
touchedObject = data.pointerCurrentRaycast.gameObject;
|
||||
if (touchedObject == null) // object is a 3D object, as we do not use Physicsraycaster, use the focusObject
|
||||
@ -254,7 +256,11 @@ namespace Passer {
|
||||
if (pointers == null)
|
||||
pointers = new InteractionPointer[maxInteractions]; // 0 = left index, 1 = right index, 2 = head, 3 = controller
|
||||
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
EventSystem eventSystem = FindAnyObjectByType<EventSystem>();
|
||||
#else
|
||||
EventSystem eventSystem = GameObject.FindObjectOfType<EventSystem>();
|
||||
#endif
|
||||
if (eventSystem == null)
|
||||
eventSystem = humanoid.gameObject.AddComponent<EventSystem>();
|
||||
|
||||
@ -344,7 +350,7 @@ namespace Passer {
|
||||
|
||||
pointer.ProcessTouch();
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
public Vector3 GetFocusPoint(int inputDeviceID) {
|
||||
return pointers[inputDeviceID].focusPosition;
|
||||
@ -528,18 +534,15 @@ namespace Passer {
|
||||
if (Camera.main == null || pointer.type != PointerType.Touch)
|
||||
return;
|
||||
|
||||
//if (eventSystem == null)
|
||||
// eventSystem = Object.FindObjectOfType<EventSystem>();
|
||||
//if (eventSystem == null)
|
||||
// return;
|
||||
|
||||
pointer.data.position = Camera.main.WorldToScreenPoint(pointer.pointerTransform.position);
|
||||
float distanceToPointer = Vector3.Distance(Camera.main.transform.position, pointer.pointerTransform.position);
|
||||
|
||||
System.Collections.Generic.List<RaycastResult> m_RaycastResultCache = new System.Collections.Generic.List<RaycastResult>();
|
||||
eventSystem.RaycastAll(pointer.data, m_RaycastResultCache);
|
||||
RaycastResult raycastResult = FindFirstRaycast(m_RaycastResultCache);
|
||||
RaycastResult raycastResult = FindFirstRaycast(m_RaycastResultCache, distanceToPointer);
|
||||
m_RaycastResultCache.Clear();
|
||||
|
||||
|
||||
if (raycastResult.gameObject != null) {
|
||||
if (pointer.type == PointerType.Touch) {
|
||||
float distance = DistanceTipToTransform(pointer.pointerTransform, raycastResult.gameObject.transform);
|
||||
@ -559,10 +562,14 @@ namespace Passer {
|
||||
}
|
||||
}
|
||||
|
||||
private new RaycastResult FindFirstRaycast(System.Collections.Generic.List<RaycastResult> raycastResults) {
|
||||
private RaycastResult FindFirstRaycast(System.Collections.Generic.List<RaycastResult> raycastResults, float pointerDistance) {
|
||||
foreach (RaycastResult result in raycastResults) {
|
||||
if (result.isValid)
|
||||
float resultDistance = Vector3.Distance(Camera.main.transform.position, result.worldPosition);
|
||||
if (result.isValid &&
|
||||
result.worldPosition != Vector3.zero &&
|
||||
Mathf.Abs(resultDistance - pointerDistance) < 0.02F) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return new RaycastResult();
|
||||
}
|
||||
@ -579,7 +586,6 @@ namespace Passer {
|
||||
}
|
||||
|
||||
private float DistanceTipToTransform(Transform fingerTip, Transform transform) {
|
||||
//Debug.DrawLine(fingerTip.position, transform.position);
|
||||
return (-transform.InverseTransformPoint(fingerTip.position).z * transform.lossyScale.z) - 0.01F;
|
||||
}
|
||||
}
|
||||
|
@ -224,7 +224,11 @@ namespace Passer {
|
||||
protected virtual void Awake() {
|
||||
Transform rootTransform = this.transform.root;
|
||||
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
interactionModule = FindAnyObjectByType<InteractionModule>();
|
||||
#else
|
||||
interactionModule = FindObjectOfType<InteractionModule>();
|
||||
#endif
|
||||
if (interactionModule == null)
|
||||
interactionModule = CreateInteractionModule();
|
||||
EventSystem eventSystem = interactionModule.GetComponent<EventSystem>();
|
||||
@ -585,7 +589,11 @@ namespace Passer {
|
||||
if (rayType != RayType.Gravity)
|
||||
return;
|
||||
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
rigidbody.linearVelocity = transform.forward * speed;
|
||||
#else
|
||||
rigidbody.velocity = transform.forward * speed;
|
||||
#endif
|
||||
}
|
||||
|
||||
public void LaunchPrefab(GameObject prefab) {
|
||||
@ -638,7 +646,7 @@ namespace Passer {
|
||||
};
|
||||
|
||||
protected GameObject previousObjectInFocus;
|
||||
protected void UpdateFocus() {
|
||||
protected virtual void UpdateFocus() {
|
||||
focusEvent.value = objectInFocus;
|
||||
|
||||
if (objectInFocus != previousObjectInFocus) {
|
||||
|
@ -658,7 +658,7 @@ namespace Passer {
|
||||
}
|
||||
|
||||
|
||||
Handle handle = attachedHandle; // attachedTransform.GetComponentInChildren<Handle>();
|
||||
Handle handle = attachedHandle;
|
||||
if (handle != null) {
|
||||
handle.socket = null;
|
||||
}
|
||||
@ -672,7 +672,7 @@ namespace Passer {
|
||||
}
|
||||
|
||||
// Released objects should be gone within 1 second or they will be reattached
|
||||
private IEnumerator ClearReleasingTransform() {
|
||||
protected IEnumerator ClearReleasingTransform() {
|
||||
yield return new WaitForSeconds(1);
|
||||
this.releasingTransform = null;
|
||||
}
|
||||
@ -694,7 +694,11 @@ namespace Passer {
|
||||
Humanoid.HumanoidNetworking.ReenableNetworkSync(objRigidbody.gameObject);
|
||||
|
||||
if (thisRigidbody != null) {
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
objRigidbody.linearVelocity = thisRigidbody.linearVelocity;
|
||||
#else
|
||||
objRigidbody.velocity = thisRigidbody.velocity;
|
||||
#endif
|
||||
objRigidbody.angularVelocity = thisRigidbody.angularVelocity;
|
||||
}
|
||||
|
||||
@ -761,7 +765,7 @@ namespace Passer {
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Rigidbody
|
||||
#endregion Rigidbody
|
||||
|
||||
#region Static Object
|
||||
|
||||
@ -807,7 +811,7 @@ namespace Passer {
|
||||
|
||||
#endregion Static Object
|
||||
|
||||
#endregion Release
|
||||
#endregion Release
|
||||
|
||||
#region Start
|
||||
|
||||
|
@ -54,7 +54,11 @@ namespace Passer {
|
||||
if (spawnPoints != null && spawnPoints.Length > 0)
|
||||
return;
|
||||
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
spawnPoints = FindObjectsByType<SpawnPoint>(FindObjectsSortMode.None);
|
||||
#else
|
||||
spawnPoints = FindObjectsOfType<SpawnPoint>();
|
||||
#endif
|
||||
if (spawnPoints.Length == 0) {
|
||||
SpawnPoint thisSpawnPoint = this.gameObject.AddComponent<SpawnPoint>();
|
||||
spawnPoints = new SpawnPoint[] { thisSpawnPoint };
|
||||
|
@ -1,18 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
public class ShowVisitorName : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
namespace Passer {
|
||||
|
||||
public class ShowVisitorName : MonoBehaviour {
|
||||
// Start is called before the first frame update
|
||||
void Start() {
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ToggleActive : MonoBehaviour {
|
||||
// Temporary helper script to implement toggling the gameobject active state
|
||||
public void Toggle() {
|
||||
this.gameObject.SetActive(!this.gameObject.activeSelf);
|
||||
namespace Passer {
|
||||
|
||||
public class ToggleActive : MonoBehaviour {
|
||||
// Temporary helper script to implement toggling the gameobject active state
|
||||
public void Toggle() {
|
||||
this.gameObject.SetActive(!this.gameObject.activeSelf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,4 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Passer {
|
||||
@ -18,7 +16,7 @@ namespace Passer {
|
||||
this.site = site;
|
||||
}
|
||||
|
||||
private void OnEnable() {
|
||||
protected void OnEnable() {
|
||||
if (site == null)
|
||||
return;
|
||||
|
||||
@ -28,7 +26,11 @@ namespace Passer {
|
||||
}
|
||||
|
||||
private void GoToSite() {
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
SiteNavigator siteNavigator = FindAnyObjectByType<SiteNavigator>();
|
||||
#else
|
||||
SiteNavigator siteNavigator = FindObjectOfType<SiteNavigator>();
|
||||
#endif
|
||||
if (siteNavigator == null) {
|
||||
Debug.LogError("Could not find a site navigator");
|
||||
return;
|
||||
|
@ -150,7 +150,11 @@ namespace Passer {
|
||||
}
|
||||
|
||||
protected void ShowSite(VisitorSites.Site site, int position) {
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
SiteNavigator siteNavigator = FindAnyObjectByType<SiteNavigator>();
|
||||
#else
|
||||
SiteNavigator siteNavigator = FindObjectOfType<SiteNavigator>();
|
||||
#endif
|
||||
if (siteNavigator == null)
|
||||
Debug.LogError("Could not find a site navigator");
|
||||
|
||||
@ -210,7 +214,7 @@ namespace Passer {
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
public void AddSite(string siteName, string siteLocation) {
|
||||
//Debug.Log("Add site " + siteName);
|
||||
@ -233,7 +237,11 @@ namespace Passer {
|
||||
}
|
||||
|
||||
private void GoToSite(VisitorSites.Site site) {
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
SiteNavigator siteNavigator = FindAnyObjectByType<SiteNavigator>();
|
||||
#else
|
||||
SiteNavigator siteNavigator = FindObjectOfType<SiteNavigator>();
|
||||
#endif
|
||||
if (siteNavigator == null) {
|
||||
Debug.LogError("Could not find a site navigator");
|
||||
return;
|
||||
|
@ -406,7 +406,11 @@ namespace Passer {
|
||||
if (avatarIndex < 0 || avatarIndex > avatars.Count)
|
||||
return;
|
||||
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
HumanoidControl humanoid = FindAnyObjectByType<HumanoidControl>();
|
||||
#else
|
||||
HumanoidControl humanoid = FindObjectOfType<HumanoidControl>();
|
||||
#endif
|
||||
if (humanoid == null)
|
||||
return;
|
||||
|
||||
@ -420,7 +424,11 @@ namespace Passer {
|
||||
}
|
||||
|
||||
private static IEnumerator RetrieveAvatarAsync(Possession possession) {
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
HumanoidControl humanoid = FindAnyObjectByType<HumanoidControl>();
|
||||
#else
|
||||
HumanoidControl humanoid = FindObjectOfType<HumanoidControl>();
|
||||
#endif
|
||||
if (humanoid == null)
|
||||
yield break;
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc84ac7c95c473c44b97c107602087b7
|
||||
guid: 86153051f48cf8c488177d8f1b7aedaa
|
||||
folderAsset: yes
|
||||
timeCreated: 1486643266
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
8
Samples~/GroceryStore/Materials/Characters/URP.meta
Normal file
8
Samples~/GroceryStore/Materials/Characters/URP.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df1bff1867e6b5e42a3d0019e53e5550
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,139 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: MakeHuman_ClassicShoes_URP
|
||||
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- _EMISSION
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 1
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap:
|
||||
RenderType: Opaque
|
||||
disabledShaderPasses:
|
||||
- MOTIONVECTORS
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BaseMap:
|
||||
m_Texture: {fileID: 2800000, guid: 15f9cf581a5a2254aa6edfdfbe4bd52d, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 2800000, guid: 15f9cf581a5a2254aa6edfdfbe4bd52d, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _SpecGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_Lightmaps:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_LightmapsInd:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- unity_ShadowMasks:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _AddPrecomputedVelocity: 0
|
||||
- _AlphaClip: 0
|
||||
- _AlphaToMask: 0
|
||||
- _Blend: 0
|
||||
- _BlendModePreserveSpecular: 1
|
||||
- _BumpScale: 1
|
||||
- _ClearCoatMask: 0
|
||||
- _ClearCoatSmoothness: 0
|
||||
- _Cull: 2
|
||||
- _Cutoff: 0.5
|
||||
- _DetailAlbedoMapScale: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _DstBlendAlpha: 0
|
||||
- _EnvironmentReflections: 1
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _QueueOffset: 0
|
||||
- _ReceiveShadows: 1
|
||||
- _Smoothness: 0.5
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _SrcBlendAlpha: 1
|
||||
- _Surface: 0
|
||||
- _UVSec: 0
|
||||
- _WorkflowMode: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _BaseColor: {r: 1, g: 1, b: 1, a: 0.9019608}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 0.9019608}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
m_AllowLocking: 1
|
||||
--- !u!114 &4097587806943858480
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 11
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
version: 9
|
@ -1,8 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5f4a7b3d888e9aa45a99a1076a352e6e
|
||||
guid: 00d69c994b1a86745864920089aba4e6
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user