Compare commits

..

No commits in common. "main" and "4.2.0" have entirely different histories.
main ... 4.2.0

204 changed files with 38390 additions and 47129 deletions

5
.gitignore vendored
View File

@ -1,5 +0,0 @@
Samples
Samples.meta
package.json
package.json.meta
Samples~.meta

View File

@ -1023,7 +1023,7 @@ namespace Passer.Humanoid {
} }
private static void CheckFaceTracking(Configuration configuration) { private static void CheckFaceTracking(Configuration configuration) {
if (DoesTypeExist("Passer.Humanoid.FaceTarget")) { if (IsFileAvailable(facePath)) {
GlobalDefine("hFACE"); GlobalDefine("hFACE");
} }
else { else {
@ -1120,9 +1120,6 @@ namespace Passer.Humanoid {
return false; return false;
if (ConfigurationCheck.packageNameList.Contains("com.unity.xr.management")) if (ConfigurationCheck.packageNameList.Contains("com.unity.xr.management"))
return true; 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")) else if (ConfigurationCheck.packageNameList.Contains("com.unity.xr.openxr"))
// Somehow management is no longer available when OpenXR is used // Somehow management is no longer available when OpenXR is used
return true; return true;

View File

@ -76,7 +76,7 @@ namespace Passer.Humanoid {
Debug.Log(questManifestPath); Debug.Log(questManifestPath);
File.Copy(questManifestPath, manifestPath); File.Copy(questManifestPath, manifestPath);
} }
catch (System.Exception ) { catch (System.Exception _) {
return; return;
} }
} }

View File

@ -855,7 +855,6 @@ namespace Passer {
else { else {
humanoid.pose.Show(humanoid); humanoid.pose.Show(humanoid);
humanoid.CopyRigToTargets(); humanoid.CopyRigToTargets();
humanoid.MatchTargetsToAvatar();
} }
} }

View File

@ -22,8 +22,7 @@ namespace Passer.Humanoid {
} }
public static GameObject GetHumanoidPlayerPrefab(string prefabPath) { public static GameObject GetHumanoidPlayerPrefab(string prefabPath) {
//GameObject prefab = PrefabUtility.LoadPrefabContents(prefabPath); GameObject prefab = PrefabUtility.LoadPrefabContents(prefabPath);
GameObject prefab = null;
return prefab; return prefab;
} }

View File

@ -1,143 +0,0 @@
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();
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 185ec4e1799d1ac4d867b69454f1cd0f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,108 +0,0 @@
/*
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
*/

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: e86563dd015c559479420645216c4a70
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -236,13 +236,7 @@ namespace Passer.Humanoid {
if (bones[i] == null || bones[i].bone == null || bones[i].bone.transform == null) if (bones[i] == null || bones[i].bone == null || bones[i].bone.transform == null)
continue; 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); Handles.FreeMoveHandle(bones[i].bone.transform.position, bones[i].bone.transform.rotation, 0.002F, Vector3.zero, DotHandleCapSaveID);
#endif
controlIds[i] = lastControlID; controlIds[i] = lastControlID;
boneIds[i] = bones[i].boneId; boneIds[i] = bones[i].boneId;
} }
@ -323,6 +317,6 @@ namespace Passer.Humanoid {
return; return;
} }
#endregion #endregion
} }
} }

View File

@ -63,9 +63,9 @@ namespace Passer {
}; };
} }
#endregion #endregion
#region Disable #region Disable
public void OnDisable() { public void OnDisable() {
if (humanoid == null) { if (humanoid == null) {
// This target is not connected to a humanoid, so we delete it // This target is not connected to a humanoid, so we delete it
@ -82,9 +82,9 @@ namespace Passer {
foreach (TargetProps props in allProps) foreach (TargetProps props in allProps)
props.SetSensor2Target(); props.SetSensor2Target();
} }
#endregion #endregion
#region Inspector #region Inspector
public override void OnInspectorGUI() { public override void OnInspectorGUI() {
if (footTarget == null || humanoid == null) if (footTarget == null || humanoid == null)
return; return;
@ -142,7 +142,7 @@ namespace Passer {
return foundHumanoid; return foundHumanoid;
} }
#region Sensors #region Sensors
private static bool showControllers = true; private static bool showControllers = true;
private void ControllerInspectors(FootTarget footTarget) { private void ControllerInspectors(FootTarget footTarget) {
showControllers = EditorGUILayout.Foldout(showControllers, "Controllers", true); showControllers = EditorGUILayout.Foldout(showControllers, "Controllers", true);
@ -157,9 +157,9 @@ namespace Passer {
EditorGUI.indentLevel--; EditorGUI.indentLevel--;
} }
} }
#endregion #endregion
#region Configuration #region Configuration
private void InitConfiguration(FootTarget footTarget) { private void InitConfiguration(FootTarget footTarget) {
if (footTarget.humanoid.avatarRig == null) if (footTarget.humanoid.avatarRig == null)
return; return;
@ -200,7 +200,7 @@ namespace Passer {
UpdateToesBones(target.toes); UpdateToesBones(target.toes);
} }
#region UpperLeg #region UpperLeg
//private string upperLegXname; //private string upperLegXname;
//private SerializedProperty upperLegMinX; //private SerializedProperty upperLegMinX;
//private SerializedProperty upperLegMaxX; //private SerializedProperty upperLegMaxX;
@ -276,9 +276,9 @@ namespace Passer {
//upperLeg.bone.maxAngles.z = upperLegMaxZ.floatValue; //upperLeg.bone.maxAngles.z = upperLegMaxZ.floatValue;
} }
#endregion #endregion
#region LowerLeg #region LowerLeg
//private string lowerLegYname; //private string lowerLegYname;
//private SerializedProperty lowerLegMinX; //private SerializedProperty lowerLegMinX;
//private SerializedProperty lowerLegMaxX; //private SerializedProperty lowerLegMaxX;
@ -326,9 +326,9 @@ namespace Passer {
//lowerLeg.bone.minAngles.x = lowerLegMinX.floatValue; //lowerLeg.bone.minAngles.x = lowerLegMinX.floatValue;
//lowerLeg.bone.maxAngles.x = lowerLegMaxX.floatValue; //lowerLeg.bone.maxAngles.x = lowerLegMaxX.floatValue;
} }
#endregion #endregion
#region Foot #region Foot
//private string footXname; //private string footXname;
//private SerializedProperty footMinX; //private SerializedProperty footMinX;
//private SerializedProperty footMaxX; //private SerializedProperty footMaxX;
@ -390,9 +390,9 @@ namespace Passer {
//foot.bone.minAngles.z = footMinZ.floatValue; //foot.bone.minAngles.z = footMinZ.floatValue;
//foot.bone.maxAngles.z = footMaxZ.floatValue; //foot.bone.maxAngles.z = footMaxZ.floatValue;
} }
#endregion #endregion
#region Toes #region Toes
//private string toesXname; //private string toesXname;
//private SerializedProperty toesMinX; //private SerializedProperty toesMinX;
//private SerializedProperty toesMaxX; //private SerializedProperty toesMaxX;
@ -441,10 +441,10 @@ namespace Passer {
//toes.bone.maxAngles.x = toesMaxX.floatValue; //toes.bone.maxAngles.x = toesMaxX.floatValue;
} }
#endregion #endregion
#endregion #endregion
#region Settings #region Settings
private SerializedProperty rotationSpeedLimitationProp; private SerializedProperty rotationSpeedLimitationProp;
private SerializedProperty slidePreventionProp; private SerializedProperty slidePreventionProp;
@ -470,9 +470,9 @@ namespace Passer {
EditorGUI.indentLevel--; EditorGUI.indentLevel--;
} }
} }
#endregion #endregion
#region Events #region Events
protected SerializedProperty groundEventProp; protected SerializedProperty groundEventProp;
@ -534,11 +534,11 @@ namespace Passer {
// } // }
//} //}
#endregion #endregion
#endregion #endregion
#region Scene #region Scene
public void OnSceneGUI() { public void OnSceneGUI() {
if (footTarget == null || humanoid == null) if (footTarget == null || humanoid == null)
@ -551,13 +551,12 @@ namespace Passer {
humanoid.pose.UpdatePose(humanoid); humanoid.pose.UpdatePose(humanoid);
else { else {
humanoid.pose.Show(humanoid); humanoid.pose.Show(humanoid);
humanoid.CopyRigToTargets(); footTarget.CopyRigToTarget();
humanoid.MatchTargetsToAvatar();
} }
} }
// update the target rig from the current foot target // update the target rig from the current foot target
humanoid.CopyTargetsToRig(); footTarget.CopyTargetToRig();
// update the avatar bones from the target rig // update the avatar bones from the target rig
humanoid.UpdateMovements(); humanoid.UpdateMovements();
// match the target rig with the new avatar pose // match the target rig with the new avatar pose
@ -569,7 +568,7 @@ namespace Passer {
humanoid.UpdateSensorsFromTargets(); humanoid.UpdateSensorsFromTargets();
} }
#endregion #endregion
public abstract class TargetProps { public abstract class TargetProps {
public SerializedProperty enabledProp; public SerializedProperty enabledProp;

View File

@ -145,6 +145,8 @@ namespace Passer.Humanoid {
InteractionPointerButton(handTarget); InteractionPointerButton(handTarget);
serializedObject.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties();
//serializedObject.Update();
//serializedObject.ApplyModifiedProperties();
} }
public static HandTarget Inspector(HandTarget handTarget, string name) { public static HandTarget Inspector(HandTarget handTarget, string name) {
@ -437,8 +439,8 @@ namespace Passer.Humanoid {
if (showSettings) { if (showSettings) {
EditorGUI.indentLevel++; EditorGUI.indentLevel++;
SerializedProperty showObjectsProp = serializedObject.FindProperty("_showRealObjects"); // Cannot use serializedPropery because showRealObjects is a getter/setter
bool showRealObjects = EditorGUILayout.Toggle("Show Real Objects", showObjectsProp.boolValue); bool showRealObjects = EditorGUILayout.Toggle("Show Real Objects", handTarget.showRealObjects);
if (showRealObjects != handTarget.showRealObjects) { if (showRealObjects != handTarget.showRealObjects) {
handTarget.showRealObjects = showRealObjects; handTarget.showRealObjects = showRealObjects;
handTarget.ShowSensors(showRealObjects, true); handTarget.ShowSensors(showRealObjects, true);
@ -695,13 +697,12 @@ namespace Passer.Humanoid {
humanoid.pose.UpdatePose(humanoid); humanoid.pose.UpdatePose(humanoid);
else { else {
humanoid.pose.Show(humanoid); humanoid.pose.Show(humanoid);
humanoid.CopyRigToTargets(); handTarget.CopyRigToTarget();
humanoid.MatchTargetsToAvatar();
} }
} }
// update the target rig from the current hand target // update the target rig from the current hand target
humanoid.CopyTargetsToRig(); handTarget.CopyTargetToRig();
// update the avatar bones from the target rig // update the avatar bones from the target rig
humanoid.UpdateMovements(); humanoid.UpdateMovements();
// match the target rig with the new avatar pose // match the target rig with the new avatar pose

View File

@ -275,7 +275,7 @@ namespace Passer.Humanoid {
if (headTarget.humanoid == null) if (headTarget.humanoid == null)
return; 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) { if (animatorProp != null && headTarget.humanoid.animatorEnabled) {
GUIContent text = new GUIContent( GUIContent text = new GUIContent(
@ -482,13 +482,12 @@ namespace Passer.Humanoid {
humanoid.pose.UpdatePose(humanoid); humanoid.pose.UpdatePose(humanoid);
else { else {
humanoid.pose.Show(humanoid); humanoid.pose.Show(humanoid);
humanoid.CopyRigToTargets(); headTarget.CopyRigToTarget();
humanoid.MatchTargetsToAvatar();
} }
} }
// update the target rig from the current head target // update the target rig from the current head target
humanoid.CopyTargetsToRig(); headTarget.CopyTargetToRig();
// update the avatar bones from the target rig // update the avatar bones from the target rig
humanoid.UpdateMovements(); humanoid.UpdateMovements();
// match the target rig with the new avatar pose // match the target rig with the new avatar pose

View File

@ -276,13 +276,12 @@ namespace Passer {
humanoid.pose.UpdatePose(humanoid); humanoid.pose.UpdatePose(humanoid);
else { else {
humanoid.pose.Show(humanoid); humanoid.pose.Show(humanoid);
humanoid.CopyRigToTargets(); hipsTarget.CopyRigToTarget();
humanoid.MatchTargetsToAvatar();
} }
} }
// update the target rig from the current hips target // update the target rig from the current hips target
humanoid.CopyTargetsToRig(); hipsTarget.CopyTargetToRig();
// update the avatar bones to match the target rig // update the avatar bones to match the target rig
humanoid.UpdateMovements(); humanoid.UpdateMovements();
// match the target rig with the new avatar pose // match the target rig with the new avatar pose

View File

@ -4,7 +4,6 @@ using UnityEngine;
namespace Passer { namespace Passer {
using Humanoid; using Humanoid;
[CanEditMultipleObjects]
[CustomEditor(typeof(Handle), true)] [CustomEditor(typeof(Handle), true)]
public class Handle_Editor : Editor { public class Handle_Editor : Editor {
@ -43,14 +42,9 @@ namespace Passer {
//if (HumanoidPreferences.help) //if (HumanoidPreferences.help)
// EditorGUILayout.HelpBox("Component to specify behaviour when grabbing the GameObject", MessageType.None); // EditorGUILayout.HelpBox("Component to specify behaviour when grabbing the GameObject", MessageType.None);
SerializedProperty handProp = serializedObject.FindProperty(nameof(Handle.hand)); handle.hand = (Handle.Hand)EditorGUILayout.EnumPopup("Hand", handle.hand);
handProp.intValue = (int)(Handle.Hand)EditorGUILayout.EnumPopup("Hand", (Handle.Hand)handProp.intValue); handle.grabType = (Handle.GrabType)EditorGUILayout.EnumPopup("Grab type", handle.grabType);
handle.range = EditorGUILayout.FloatField("Range", handle.range);
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); HandPoseInspector(handle);
CheckHandTarget(handle); CheckHandTarget(handle);

View File

@ -4,7 +4,7 @@ using UnityEngine;
namespace Passer { namespace Passer {
using Humanoid; using Humanoid;
[CustomEditor(typeof(ControllerInput), true)] [CustomEditor(typeof(ControllerInput))]
public class ControllerInput_Editor : Editor { public class ControllerInput_Editor : Editor {
protected ControllerInput controllerInput; protected ControllerInput controllerInput;

View File

@ -4,21 +4,19 @@ 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) 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://git.passer.life/HumanoidControl/HumanoidControl_Free.git) Use the link from 'Clone with HTTP' (for example: https://gitlab.passervr.com/passer/unity/humanoidcontrol4_free.git)
In this way you can always retrieve the latest version by pressing the `Update` button in the Package Manager. 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:https://git.passer.life/HumanoidControl/HumanoidControl_Free.git#4.1.0. 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.
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. 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 ChangeLog and Releases
====================== ======================
All releases with UnityPackages and links for the Unity Package Manager: [Tags page](https://git.passer.life/HumanoidControl/HumanoidControl_Free/tags). 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)
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 Documentation
============= =============
For the latest version of the documentation, see [PasserVR HumanoidControl Documentation](https://docs.humanoidcontrol.com/) For the latest version of the documentation, see [PasserVR HumanoidControl Documentation](https://passervr.com/apis/HumanoidControl/Unity/index.html)
Video Video
===== =====

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ddd35f516c607da4ab4f97b210606169
timeCreated: 1453468358
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 875a66c1e6398184192242a8674906b3 guid: ed397d272bcc7c14eb9d4a69d7ba578f
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}

View File

@ -5,12 +5,11 @@ PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 2 serializedVersion: 2
m_Modification: m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0} m_TransformParent: {fileID: 0}
m_Modifications: m_Modifications:
- target: {fileID: 100156, guid: d00d05e5d77de9f438f68e5f5367a627, type: 3} - target: {fileID: 100156, guid: d00d05e5d77de9f438f68e5f5367a627, type: 3}
propertyPath: m_Name propertyPath: m_Name
value: MakeHuman_simple_TP_URP value: MakeHuman_simple_TP Variant
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 400156, guid: d00d05e5d77de9f438f68e5f5367a627, type: 3} - target: {fileID: 400156, guid: d00d05e5d77de9f438f68e5f5367a627, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
@ -57,23 +56,20 @@ PrefabInstance:
value: 0 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 13700000, guid: d00d05e5d77de9f438f68e5f5367a627, type: 3} - target: {fileID: 13700000, guid: d00d05e5d77de9f438f68e5f5367a627, type: 3}
propertyPath: 'm_Materials.Array.data[0]' propertyPath: m_Materials.Array.data[0]
value: value:
objectReference: {fileID: 2100000, guid: ce08b92c0a6a4224d8df78eff1db7d93, type: 2} objectReference: {fileID: 2100000, guid: 457a25bacfd81c34d8db8c9aad406f55, type: 2}
- target: {fileID: 13700002, guid: d00d05e5d77de9f438f68e5f5367a627, type: 3} - target: {fileID: 13700002, guid: d00d05e5d77de9f438f68e5f5367a627, type: 3}
propertyPath: 'm_Materials.Array.data[0]' propertyPath: m_Materials.Array.data[0]
value: value:
objectReference: {fileID: 2100000, guid: 00d69c994b1a86745864920089aba4e6, type: 2} objectReference: {fileID: 2100000, guid: 0ca0d02c198ab15498856b7fa22650b6, type: 2}
- target: {fileID: 13700004, guid: d00d05e5d77de9f438f68e5f5367a627, type: 3} - target: {fileID: 13700004, guid: d00d05e5d77de9f438f68e5f5367a627, type: 3}
propertyPath: 'm_Materials.Array.data[0]' propertyPath: m_Materials.Array.data[0]
value: value:
objectReference: {fileID: 2100000, guid: 731d624f2e3c1d2488ed97fadc4bdceb, type: 2} objectReference: {fileID: 2100000, guid: 1924927a790c5b24eb77f51e7fffdbb5, type: 2}
- target: {fileID: 13700006, guid: d00d05e5d77de9f438f68e5f5367a627, type: 3} - target: {fileID: 13700006, guid: d00d05e5d77de9f438f68e5f5367a627, type: 3}
propertyPath: 'm_Materials.Array.data[0]' propertyPath: m_Materials.Array.data[0]
value: value:
objectReference: {fileID: 2100000, guid: accc8d449e971a341b8b5ad32b0ba19c, type: 2} objectReference: {fileID: 2100000, guid: 5603bff079abbbf40b7d0569a9ca2e45, type: 2}
m_RemovedComponents: [] m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: d00d05e5d77de9f438f68e5f5367a627, type: 3} m_SourcePrefab: {fileID: 100100000, guid: d00d05e5d77de9f438f68e5f5367a627, type: 3}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 4695857d04e1e734faab072549aa786f guid: 86f7ba3098b1d6d4f846836e83c3cb42
PrefabImporter: PrefabImporter:
externalObjects: {} externalObjects: {}
userData: userData:

View File

@ -1,16 +1,27 @@
%YAML 1.1 %YAML 1.1
%TAG !u! tag:unity3d.com,2011: %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 --- !u!1 &1102845541656492
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInternal: {fileID: 100100000}
m_PrefabAsset: {fileID: 0} serializedVersion: 5
serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 224080167443833264} - component: {fileID: 224080167443833264}
- component: {fileID: 222382479412892260} - component: {fileID: 222382479412892260}
- component: {fileID: 114935358240423544} - component: {fileID: 114935358240423544}
- component: {fileID: 114123306642843232}
m_Layer: 0 m_Layer: 0
m_Name: Text m_Name: Text
m_TagString: Untagged m_TagString: Untagged
@ -18,53 +29,91 @@ GameObject:
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 1
--- !u!224 &224080167443833264 --- !u!1 &1547744635115364
RectTransform: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInternal: {fileID: 100100000}
m_PrefabAsset: {fileID: 0} serializedVersion: 5
m_GameObject: {fileID: 1102845541656492} m_Component:
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - component: {fileID: 224268792594220398}
m_LocalPosition: {x: 0, y: 0, z: 0} - component: {fileID: 223133106560874972}
m_LocalScale: {x: 1, y: 1, z: 1} - component: {fileID: 114215111648024090}
m_ConstrainProportionsScale: 0 - component: {fileID: 114000307814322182}
m_Children: [] m_Layer: 0
m_Father: {fileID: 224268792594220398} m_Name: NetworkingStatusCanvas
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_TagString: Untagged
m_AnchorMin: {x: 0.5, y: 0.5} m_Icon: {fileID: 0}
m_AnchorMax: {x: 0.5, y: 0.5} m_NavMeshLayer: 0
m_AnchoredPosition: {x: 0, y: 0} m_StaticEditorFlags: 0
m_SizeDelta: {x: 160, y: 30} m_IsActive: 1
m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &114000307814322182
--- !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: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInternal: {fileID: 100100000}
m_PrefabAsset: {fileID: 0} 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_GameObject: {fileID: 1102845541656492} m_GameObject: {fileID: 1102845541656492}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} 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
--- !u!114 &114935358240423544
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1102845541656492}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
m_RaycastTarget: 1 m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData: m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14 m_FontSize: 14
@ -79,51 +128,17 @@ MonoBehaviour:
m_VerticalOverflow: 0 m_VerticalOverflow: 0
m_LineSpacing: 1 m_LineSpacing: 1
m_Text: New Text m_Text: New Text
--- !u!1 &1547744635115364 --- !u!222 &222382479412892260
GameObject: CanvasRenderer:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInternal: {fileID: 100100000}
m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1102845541656492}
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 --- !u!223 &223133106560874972
Canvas: Canvas:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInternal: {fileID: 100100000}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1547744635115364} m_GameObject: {fileID: 1547744635115364}
m_Enabled: 1 m_Enabled: 1
serializedVersion: 3 serializedVersion: 3
@ -135,49 +150,45 @@ Canvas:
m_OverrideSorting: 0 m_OverrideSorting: 0
m_OverridePixelPerfect: 0 m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0 m_SortingBucketNormalizedSize: 0
m_VertexColorAlwaysGammaSpace: 0
m_AdditionalShaderChannelsFlag: 25 m_AdditionalShaderChannelsFlag: 25
m_UpdateRectTransformForStandalone: 0
m_SortingLayerID: 0 m_SortingLayerID: 0
m_SortingOrder: 0 m_SortingOrder: 0
m_TargetDisplay: 0 m_TargetDisplay: 0
--- !u!114 &114215111648024090 --- !u!224 &224080167443833264
MonoBehaviour: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInternal: {fileID: 100100000}
m_PrefabAsset: {fileID: 0} 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}
m_GameObject: {fileID: 1547744635115364} m_GameObject: {fileID: 1547744635115364}
m_Enabled: 1 m_LocalRotation: {x: -0.0000015646192, y: -0.0000072655666, z: -0.0000067270753,
m_EditorHideFlags: 0 w: 1}
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} m_LocalPosition: {x: 0, y: 0, z: 0.5}
m_Name: m_LocalScale: {x: 0.001, y: 0.001, z: 0.001}
m_EditorClassIdentifier: m_Children:
m_UiScaleMode: 0 - {fileID: 224080167443833264}
m_ReferencePixelsPerUnit: 100 m_Father: {fileID: 0}
m_ScaleFactor: 1 m_RootOrder: 0
m_ReferenceResolution: {x: 800, y: 600} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_ScreenMatchMode: 0 m_AnchorMin: {x: 0, y: 0}
m_MatchWidthOrHeight: 0 m_AnchorMax: {x: 0, y: 0}
m_PhysicalUnit: 3 m_AnchoredPosition: {x: 0, y: 0}
m_FallbackScreenDPI: 96 m_SizeDelta: {x: 160, y: 40}
m_DefaultSpriteDPI: 96 m_Pivot: {x: 0.5, y: 0.5}
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

View File

@ -13,7 +13,7 @@ namespace Passer.Humanoid {
} }
public BodyRotation bodyRotation; public BodyRotation bodyRotation;
protected float torsoLength; private float torsoLength;
private Quaternion torsoUprightOrientation; private Quaternion torsoUprightOrientation;
@ -67,7 +67,7 @@ namespace Passer.Humanoid {
private Vector3 leftFootPosition; private Vector3 leftFootPosition;
private Quaternion rightFootRotation; private Quaternion rightFootRotation;
private Vector3 rightFootPosition; private Vector3 rightFootPosition;
public void StoreTargets() { private void StoreTargets() {
neckRotation = hipsTarget.humanoid.headTarget.neck.target.transform.rotation; neckRotation = hipsTarget.humanoid.headTarget.neck.target.transform.rotation;
neckPosition = hipsTarget.humanoid.headTarget.neck.target.transform.position; neckPosition = hipsTarget.humanoid.headTarget.neck.target.transform.position;
leftHandRotation = hipsTarget.humanoid.leftHandTarget.hand.target.transform.rotation; leftHandRotation = hipsTarget.humanoid.leftHandTarget.hand.target.transform.rotation;
@ -80,7 +80,7 @@ namespace Passer.Humanoid {
rightFootPosition = hipsTarget.humanoid.rightFootTarget.foot.target.transform.localPosition; rightFootPosition = hipsTarget.humanoid.rightFootTarget.foot.target.transform.localPosition;
} }
public void RestoreTargets() { private void RestoreTargets() {
hipsTarget.humanoid.headTarget.neck.target.transform.rotation = neckRotation; hipsTarget.humanoid.headTarget.neck.target.transform.rotation = neckRotation;
hipsTarget.humanoid.headTarget.neck.target.transform.position = neckPosition; hipsTarget.humanoid.headTarget.neck.target.transform.position = neckPosition;
hipsTarget.humanoid.leftHandTarget.hand.target.transform.rotation = leftHandRotation; hipsTarget.humanoid.leftHandTarget.hand.target.transform.rotation = leftHandRotation;
@ -177,7 +177,7 @@ namespace Passer.Humanoid {
oldPosition = neckPosition; oldPosition = neckPosition;
} }
public Vector3 CalculateHipsPosition() { private Vector3 CalculateHipsPosition() {
HumanoidControl humanoid = hipsTarget.humanoid; HumanoidControl humanoid = hipsTarget.humanoid;
HeadTarget headTarget = humanoid.headTarget; HeadTarget headTarget = humanoid.headTarget;

View File

@ -6,94 +6,7 @@ namespace Passer.Humanoid {
/// <summary> /// <summary>
/// A tracker wich can be used for custom tracking solutions /// A tracker wich can be used for custom tracking solutions
/// </summary> /// </summary>
/// This tracking option supports custom trackers and sensors for a humanoid. /// 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] [System.Serializable]
public class CustomTracker : HumanoidTracker { public class CustomTracker : HumanoidTracker {

View File

@ -86,7 +86,7 @@ namespace Passer.Tracking {
} }
if (OculusDevice.GetHandState(OculusDevice.Step.Render, isLeft ? OculusDevice.Hand.HandLeft : OculusDevice.Hand.HandRight, ref handState)) { if (OculusDevice.GetHandState(OculusDevice.Step.Render, isLeft ? OculusDevice.Hand.HandLeft : OculusDevice.Hand.HandRight, ref handState)) {
if ((handState.Status & OculusDevice.HandStatus.HandTracked) == 0) { if (handState.Status == 0) {
status = Tracker.Status.Present; status = Tracker.Status.Present;
DisableRenderer(); DisableRenderer();
return; return;

View File

@ -0,0 +1,84 @@
%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}

View File

@ -1,8 +1,8 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: accc8d449e971a341b8b5ad32b0ba19c guid: 0e0e467473c4c304691fb218ad5d5411
timeCreated: 1562924722
licenseType: Free
NativeFormatImporter: NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:

View File

@ -0,0 +1,84 @@
%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}

View File

@ -1,8 +1,8 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: ce08b92c0a6a4224d8df78eff1db7d93 guid: f78c353d457baeb44987e0ae9bc0a529
timeCreated: 1562924724
licenseType: Free
NativeFormatImporter: NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:

View File

@ -52,11 +52,7 @@ namespace Passer.Tracking {
if (_hmd != null) if (_hmd != null)
return _hmd; return _hmd;
#if UNITY_6000_0_OR_NEWER
_hmd = FindAnyObjectByType<UnityXRHmd>();
#else
_hmd = FindObjectOfType<UnityXRHmd>(); _hmd = FindObjectOfType<UnityXRHmd>();
#endif
return _hmd; return _hmd;
} }
} }
@ -139,7 +135,7 @@ namespace Passer.Tracking {
Object.DestroyImmediate(plane.gameObject); Object.DestroyImmediate(plane.gameObject);
} }
#endregion Hmd #endregion Hmd
#region Controller #region Controller
@ -242,7 +238,7 @@ namespace Passer.Tracking {
#endregion #endregion
#endregion Manage #endregion Manage
#region Init #region Init

View File

@ -7,17 +7,15 @@ namespace Passer.Tracking {
public class UnityXRController : ControllerComponent { public class UnityXRController : ControllerComponent {
#if pUNITYXR #if pUNITYXR
//public TrackerComponent tracker;
//public Transform sensorTransform {
// get { return this.transform; }
//}
protected InputDevice device; protected InputDevice device;
protected XRNode xrNode; protected XRNode xrNode;
protected enum LoadedDeviceType {
None,
Oculus,
OpenXR,
Varjo,
}
protected LoadedDeviceType loadedDevice = LoadedDeviceType.None;
public GameObject model; public GameObject model;
#region Manage #region Manage
@ -137,13 +135,6 @@ namespace Passer.Tracking {
InputDevices.deviceConnected += OnDeviceConnected; InputDevices.deviceConnected += OnDeviceConnected;
InputDevices.deviceDisconnected += OnDeviceDisconnected; 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> /// <summary>
@ -191,25 +182,19 @@ namespace Passer.Tracking {
status = Tracker.Status.Present; status = Tracker.Status.Present;
bool isTracked = false;
if (device.TryGetFeatureValue(CommonUsages.isTracked, out isTracked)) {
Vector3 position; Vector3 position;
if (isTracked && device.TryGetFeatureValue(CommonUsages.devicePosition, out position)) { if (device.TryGetFeatureValue(CommonUsages.devicePosition, out position)) {
transform.position = trackerTransform.TransformPoint(position); transform.position = trackerTransform.TransformPoint(position);
positionConfidence = 1; positionConfidence = 1;
status = Tracker.Status.Tracking; status = Tracker.Status.Tracking;
} }
Quaternion rotation; Quaternion rotation;
if (isTracked && device.TryGetFeatureValue(CommonUsages.deviceRotation, out rotation)) { if (device.TryGetFeatureValue(CommonUsages.deviceRotation, out rotation)) {
if (loadedDevice == LoadedDeviceType.OpenXR ||
loadedDevice == LoadedDeviceType.Varjo)
rotation *= Quaternion.AngleAxis(45, Vector3.right);
transform.rotation = trackerTransform.rotation * rotation; transform.rotation = trackerTransform.rotation * rotation;
rotationConfidence = 1; rotationConfidence = 1;
status = Tracker.Status.Tracking; status = Tracker.Status.Tracking;
} }
}
UpdateInput(); UpdateInput();
@ -264,14 +249,6 @@ namespace Passer.Tracking {
renderers[i].enabled = showModel; 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 #endregion Init
#endif #endif
} }

View File

@ -139,12 +139,6 @@ namespace Passer.Humanoid {
controllerInputSide.option |= controller.option > 0; 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 // arm model for 3DOF tracking: position is calculated from rotation
static public Vector3 CalculateHandPosition(HandTarget handTarget, Vector3 sensor2TargetPosition) { static public Vector3 CalculateHandPosition(HandTarget handTarget, Vector3 sensor2TargetPosition) {
Quaternion hipsYRotation = Quaternion.AngleAxis(handTarget.humanoid.hipsTarget.transform.eulerAngles.y, handTarget.humanoid.up); Quaternion hipsYRotation = Quaternion.AngleAxis(handTarget.humanoid.hipsTarget.transform.eulerAngles.y, handTarget.humanoid.up);

View File

@ -82,17 +82,6 @@ namespace Passer.Humanoid {
return sensorComponent as UnityXRHmd; 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 #endregion
#region Start #region Start

View File

@ -357,14 +357,11 @@ namespace Passer.Humanoid {
#region Avatar #region Avatar
public event OnChangeAvatar OnChangeAvatarEvent; private float GetAvatarNeckHeight() {
public delegate void OnChangeAvatar();
protected float GetAvatarNeckHeight() {
if (avatarRig == null) if (avatarRig == null)
return headTarget.transform.localPosition.y; return headTarget.transform.localPosition.y;
Transform avatarNeck = headTarget.neck.bone.transform; Transform avatarNeck = headTarget.neck.bone.transform; // avatarRig.GetBoneTransform(HumanBodyBones.Neck);
if (avatarNeck != null) { if (avatarNeck != null) {
float neckHeight = avatarNeck.position.y - avatarRig.transform.position.y; float neckHeight = avatarNeck.position.y - avatarRig.transform.position.y;
return neckHeight; return neckHeight;
@ -396,7 +393,7 @@ namespace Passer.Humanoid {
} }
} }
public virtual void LocalChangeAvatar(GameObject avatarPrefab) { public void LocalChangeAvatar(GameObject avatarPrefab) {
if (avatarPrefab == null) if (avatarPrefab == null)
return; return;
@ -453,11 +450,6 @@ namespace Passer.Humanoid {
AddCharacterColliders(); AddCharacterColliders();
avatarNeckHeight = GetAvatarNeckHeight(); avatarNeckHeight = GetAvatarNeckHeight();
#if pUNITYXR
if (isRemote == false && headTarget.unityXR != null)
headTarget.unityXR.UpdateSensorLocation();
#endif
switch (scaling) { switch (scaling) {
case ScalingType.SetHeightToAvatar: case ScalingType.SetHeightToAvatar:
SetTrackingHeightToAvatar(); SetTrackingHeightToAvatar();
@ -471,11 +463,9 @@ namespace Passer.Humanoid {
default: default:
break; break;
} }
OnChangeAvatarEvent?.Invoke();
} }
public virtual void InitializeAvatar() { public void InitializeAvatar() {
avatarRig = GetAvatar(this.gameObject); avatarRig = GetAvatar(this.gameObject);
// Move the animator controller to the targets rig for proper animation support // Move the animator controller to the targets rig for proper animation support
@ -718,7 +708,7 @@ namespace Passer.Humanoid {
rightFootTarget.MatchTargetsToAvatar(); rightFootTarget.MatchTargetsToAvatar();
} }
protected void UpdateTargetsAndMovements() { private void UpdateTargetsAndMovements() {
CopyTargetsToRig(); CopyTargetsToRig();
UpdateTargets(); UpdateTargets();
@ -751,7 +741,7 @@ namespace Passer.Humanoid {
} }
/// <summary>Copies the pose of the target rig to the avatar</summary> /// <summary>Copies the pose of the target rig to the avatar</summary>
public void CopyTargetsToRig() { private void CopyTargetsToRig() {
hipsTarget.CopyTargetToRig(); hipsTarget.CopyTargetToRig();
headTarget.CopyTargetToRig(); headTarget.CopyTargetToRig();
leftHandTarget.CopyTargetToRig(); leftHandTarget.CopyTargetToRig();
@ -1095,7 +1085,7 @@ namespace Passer.Humanoid {
} }
} }
protected TraditionalDevice traditionalInput; private TraditionalDevice traditionalInput;
protected void InitTrackers() { protected void InitTrackers() {
_trackers = new HumanoidTracker[] { _trackers = new HumanoidTracker[] {
@ -1253,7 +1243,22 @@ namespace Passer.Humanoid {
/// taller or smaller than the avatar itself. /// taller or smaller than the avatar itself.
/// It retains 1:1 tracking and the X/Z position of the player are not affected. /// It retains 1:1 tracking and the X/Z position of the player are not affected.
protected void SetTrackingHeightToAvatar() { 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; Vector3 neckPosition;
if (headTarget.neck.target.confidence.position > 0.2F) if (headTarget.neck.target.confidence.position > 0.2F)
neckPosition = headTarget.neck.target.transform.position; neckPosition = headTarget.neck.target.transform.position;
@ -1266,6 +1271,7 @@ namespace Passer.Humanoid {
float deltaY = avatarNeckHeight - playersNeckHeight; float deltaY = avatarNeckHeight - playersNeckHeight;
AdjustTrackingHeight(deltaY); AdjustTrackingHeight(deltaY);
//#endif
} }
//public void MoveTrackingHeightToAvatar() { //public void MoveTrackingHeightToAvatar() {
@ -1316,7 +1322,7 @@ namespace Passer.Humanoid {
#region Update #region Update
protected virtual void Update() { protected void Update() {
Controllers.Clear(); Controllers.Clear();
UpdatePose(); UpdatePose();
traditionalInput.UpdateGameController(gameController); traditionalInput.UpdateGameController(gameController);
@ -1327,7 +1333,7 @@ namespace Passer.Humanoid {
UpdatePoseEvent(); UpdatePoseEvent();
} }
protected virtual void FixedUpdate() { protected void FixedUpdate() {
DetermineCollision(); DetermineCollision();
CalculateMovement(); CalculateMovement();
CheckBodyPull(); CheckBodyPull();
@ -1341,7 +1347,7 @@ namespace Passer.Humanoid {
} }
protected virtual void LateUpdate() { protected void LateUpdate() {
PostAnimationCorrection(); PostAnimationCorrection();
@ -1388,15 +1394,15 @@ namespace Passer.Humanoid {
} }
[HideInInspector] [HideInInspector]
protected Vector3 lastHumanoidPos; private Vector3 lastHumanoidPos;
[HideInInspector] [HideInInspector]
protected float lastNeckHeight; private float lastNeckHeight;
[HideInInspector] [HideInInspector]
protected Vector3 lastHeadPosition; private Vector3 lastHeadPosition;
[HideInInspector] [HideInInspector]
protected Quaternion lastHeadRotation; private Quaternion lastHeadRotation;
[HideInInspector] [HideInInspector]
protected float lastHeadDirection; private float lastHeadDirection;
public event OnNewNeckHeight OnNewNeckHeightEvent; public event OnNewNeckHeight OnNewNeckHeightEvent;
public delegate void OnNewNeckHeight(float neckHeight); public delegate void OnNewNeckHeight(float neckHeight);
@ -1426,16 +1432,7 @@ namespace Passer.Humanoid {
#region Calibration #region Calibration
public virtual void SetStartPosition() { public 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> /// <summary>Calibrates the tracking with the player</summary>
@ -1938,7 +1935,7 @@ namespace Passer.Humanoid {
[HideInInspector] [HideInInspector]
private readonly float colliderRadius = 0.15F; private readonly float colliderRadius = 0.15F;
protected void AddCharacterColliders() { private void AddCharacterColliders() {
if (avatarRig == null || hipsTarget.hips.bone.transform == null || isRemote || !physics) if (avatarRig == null || hipsTarget.hips.bone.transform == null || isRemote || !physics)
return; return;
@ -2071,7 +2068,7 @@ namespace Passer.Humanoid {
rightUpperLegCollider.center = new Vector3(0, -rightUpperLeg.length / 2, 0); rightUpperLegCollider.center = new Vector3(0, -rightUpperLeg.length / 2, 0);
} }
protected void DetermineCollision() { private void DetermineCollision() {
if (proximitySpeed) { if (proximitySpeed) {
//float angle = Vector3.Angle(hitNormal, targetVelocity); //float angle = Vector3.Angle(hitNormal, targetVelocity);
collided = (triggerEntered && bodyCapsule.radius <= 0.25f); collided = (triggerEntered && bodyCapsule.radius <= 0.25f);
@ -2083,7 +2080,7 @@ namespace Passer.Humanoid {
hitNormal = Vector3.zero; hitNormal = Vector3.zero;
} }
public virtual bool IsMyRigidbody(Rigidbody rigidbody) { public bool IsMyRigidbody(Rigidbody rigidbody) {
return return
rigidbody != null && ( rigidbody != null && (
rigidbody == humanoidRigidbody || rigidbody == humanoidRigidbody ||
@ -2140,8 +2137,6 @@ namespace Passer.Humanoid {
/// Correct floating avatars when user is taller than the avatar /// Correct floating avatars when user is taller than the avatar
/// </summary> /// </summary>
public bool floatCorrection = false; public bool floatCorrection = false;
public bool floatReverting = false;
private float floatCorrectionDistance = 0.0F;
protected void CheckGrounded() { protected void CheckGrounded() {
Vector3 footBase = GetHumanoidPosition(); Vector3 footBase = GetHumanoidPosition();
@ -2181,24 +2176,8 @@ namespace Passer.Humanoid {
if (floatCorrection) { if (floatCorrection) {
float leftFootBoneDistance = leftFootTarget.foot.bone.transform.position.y - leftFootTarget.foot.target.transform.position.y; 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; float rightFootBoneDistance = rightFootTarget.foot.bone.transform.position.y - rightFootTarget.foot.target.transform.position.y;
if (leftFootBoneDistance > 0.02F && rightFootBoneDistance > 0.02F) { if (leftFootBoneDistance > 0.02F && rightFootBoneDistance > 0.02F)
float correction = -0.01F; AdjustTrackingHeight(-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}");
}
} }
} }
@ -2319,9 +2298,9 @@ namespace Passer.Humanoid {
#endregion #endregion
[HideInInspector] [HideInInspector]
protected float lastTime; private float lastTime;
protected virtual void CalculateVelocityAcceleration() { private void CalculateVelocityAcceleration() {
if (lastTime > 0) { if (lastTime > 0) {
float deltaTime = Time.time - lastTime; float deltaTime = Time.time - lastTime;

View File

@ -1,9 +1,11 @@
namespace Passer.Humanoid { namespace Passer.Humanoid {
/// \author PasserVR /// \author PasserVR
/// \version 4 /// \version 4.0
/// \mainpage %Humanoid Control for Unity /// \mainpage %Humanoid Control for Unity
/// ///
/// Note: this documentation is still work in progress...
///
/// Main components /// Main components
/// --------------- /// ---------------
/// * \ref HumanoidControl "Humanoid Control" /// * \ref HumanoidControl "Humanoid Control"
@ -12,18 +14,12 @@
/// ------- /// -------
/// * \ref UnityXRTracker "UnityXR" /// * \ref UnityXRTracker "UnityXR"
/// * \ref QuestDoc "Meta Rift/Quest" /// * \ref QuestDoc "Meta Rift/Quest"
/// * \ref LeapTracker "Ultraleap"
/// * \ref ViveTrackerDoc "HTC Vive Trackers"
/// ///
/// Input /// Input
/// ----- /// -----
/// * ControllerInput /// * ControllerInput
/// * InteractionPointer /// * InteractionPointer
/// ///
/// Avatars
/// -------
/// * Pose
///
/// Generic tools /// Generic tools
/// ------------- /// -------------
/// * TeleportTarget /// * TeleportTarget
@ -32,63 +28,6 @@
/// ///
/// Networking /// Networking
/// ---------- /// ----------
/// * \ref PhotonPunDoc "Photon PUN"
/// * NetworkingStarter /// * 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.
} }

View File

@ -32,11 +32,7 @@ namespace Passer.Humanoid {
inputModule = humanoid.GetComponent<InteractionModule>(); inputModule = humanoid.GetComponent<InteractionModule>();
if (inputModule == null) { if (inputModule == null) {
#if UNITY_6000_0_OR_NEWER
inputModule = Object.FindAnyObjectByType<InteractionModule>();
#else
inputModule = Object.FindObjectOfType<InteractionModule>(); inputModule = Object.FindObjectOfType<InteractionModule>();
#endif
if (inputModule == null) { if (inputModule == null) {
inputModule = humanoid.gameObject.AddComponent<InteractionModule>(); inputModule = humanoid.gameObject.AddComponent<InteractionModule>();
} }
@ -45,7 +41,7 @@ namespace Passer.Humanoid {
inputModule.EnableTouchInput(humanoid, isLeft, 0); inputModule.EnableTouchInput(humanoid, isLeft, 0);
} }
public virtual HandSocket CreateGrabSocket() { public HandSocket CreateGrabSocket() {
if (hand.bone.transform == null) if (hand.bone.transform == null)
return null; return null;
@ -118,7 +114,7 @@ namespace Passer.Humanoid {
} }
} }
protected void DeterminePalmPosition() { private void DeterminePalmPosition() {
if (hand.bone.transform == null) if (hand.bone.transform == null)
return; return;
@ -662,37 +658,32 @@ namespace Passer.Humanoid {
return false; return false;
} }
// We need to determine this here because the kinematic state
// can change when grabbing
grabbedKinematicRigidbody = objRigidbody.isKinematic;
if (objRigidbody.isKinematic) if (objRigidbody.isKinematic)
GrabStaticWithoutHandle(objRigidbody.gameObject); GrabStaticWithoutHandle(objRigidbody.gameObject);
else else
GrabRigidbodyParenting(objRigidbody); GrabRigidbodyParenting(objRigidbody);
grabbedRigidbody = true; grabbedRigidbody = true;
grabbedKinematicRigidbody = objRigidbody.isKinematic;
return true; return true;
} }
protected virtual bool GrabRigidbodyParenting(Rigidbody objRigidbody) { protected virtual bool GrabRigidbodyParenting(Rigidbody objRigidbody) {
GameObject obj = objRigidbody.gameObject; GameObject obj = objRigidbody.gameObject;
if (handRigidbody == null) if (handRigidbody == null) {
Debug.LogError("Hand no longer has a rigidbody..."); Debug.LogError("Hand no longer has a rigidbody...");
}
if (handRigidbody != null) RigidbodyDisabled.ParentRigidbody(handRigidbody, objRigidbody);
handRigidbody.mass = objRigidbody.mass;
HumanoidNetworking.DisableNetworkSync(objRigidbody.gameObject); HumanoidNetworking.DisableNetworkSync(objRigidbody.gameObject);
if (!humanoid.isRemote) if (!humanoid.isRemote)
HumanoidNetworking.TakeOwnership(objRigidbody.gameObject); HumanoidNetworking.TakeOwnership(objRigidbody.gameObject);
RigidbodyDisabled.ParentRigidbody(handRigidbody, objRigidbody); if (Application.isPlaying)
Object.Destroy(objRigidbody);
//if (Application.isPlaying) else
// Object.Destroy(objRigidbody); Object.DestroyImmediate(objRigidbody, true);
//else
// Object.DestroyImmediate(objRigidbody, true);
grabbedObject = obj; grabbedObject = obj;
return true; return true;
@ -825,15 +816,11 @@ namespace Passer.Humanoid {
} }
protected virtual void LetGoRigidbodyWithoutHandle() { protected void LetGoRigidbodyWithoutHandle() {
Rigidbody objRigidbody = RigidbodyDisabled.UnparentRigidbody(handPalm, grabbedObject.transform); Rigidbody objRigidbody = RigidbodyDisabled.UnparentRigidbody(handPalm, grabbedObject.transform);
if (objRigidbody != null && !objRigidbody.isKinematic) { if (objRigidbody != null && !objRigidbody.isKinematic) {
if (handRigidbody != null) { if (handRigidbody != null) {
#if UNITY_6000_0_OR_NEWER
objRigidbody.linearVelocity = handRigidbody.linearVelocity;
#else
objRigidbody.velocity = handRigidbody.velocity; objRigidbody.velocity = handRigidbody.velocity;
#endif
objRigidbody.angularVelocity = handRigidbody.angularVelocity; objRigidbody.angularVelocity = handRigidbody.angularVelocity;
} }
HumanoidNetworking.ReenableNetworkSync(objRigidbody.gameObject); HumanoidNetworking.ReenableNetworkSync(objRigidbody.gameObject);
@ -842,11 +829,11 @@ namespace Passer.Humanoid {
LetGoStaticWithoutHandle(); LetGoStaticWithoutHandle();
} }
protected virtual void LetGoStaticWithoutHandle() { protected void LetGoStaticWithoutHandle() {
grabSocket.ReleaseStaticJoint(); grabSocket.ReleaseStaticJoint();
} }
protected virtual void LetGoRigidbody(Rigidbody grabbedRigidbody) { protected void LetGoRigidbody(Rigidbody grabbedRigidbody) {
DebugLog("LetGoRigidbody"); DebugLog("LetGoRigidbody");
if (grabbedRigidbody != null) { if (grabbedRigidbody != null) {
@ -860,24 +847,16 @@ namespace Passer.Humanoid {
} }
//grabbedRigidbody.centerOfMass = handTarget.storedCOM; //grabbedRigidbody.centerOfMass = handTarget.storedCOM;
if (grabbedRigidbody.isKinematic == false) {
#if UNITY_6000_0_OR_NEWER
grabbedRigidbody.linearVelocity = handRigidbody.linearVelocity;
#else
grabbedRigidbody.velocity = handRigidbody.velocity; grabbedRigidbody.velocity = handRigidbody.velocity;
#endif
grabbedRigidbody.angularVelocity = handRigidbody.angularVelocity; grabbedRigidbody.angularVelocity = handRigidbody.angularVelocity;
}
if (grabbedHandle != null) if (grabbedHandle != null)
LetGoHandle(grabbedHandle); LetGoHandle(grabbedHandle);
handRigidbody.mass = 1;
} }
this.grabbedRigidbody = false; this.grabbedRigidbody = false;
} }
protected virtual void LetGoHandle(Handle handle) { protected void LetGoHandle(Handle handle) {
DebugLog("LetGoHandle " + handle); DebugLog("LetGoHandle " + handle);
if (Application.isPlaying) { if (Application.isPlaying) {
if (grabbedHandle != null) { if (grabbedHandle != null) {

View File

@ -53,13 +53,8 @@ namespace Passer.Humanoid {
handTarget.handRigidbody = handTarget.hand.bone.transform.gameObject.AddComponent<Rigidbody>(); handTarget.handRigidbody = handTarget.hand.bone.transform.gameObject.AddComponent<Rigidbody>();
} }
handTarget.handRigidbody.mass = 1; 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.drag = 0;
handTarget.handRigidbody.angularDrag = 10; handTarget.handRigidbody.angularDrag = 10;
#endif
handTarget.handRigidbody.useGravity = false; handTarget.handRigidbody.useGravity = false;
handTarget.handRigidbody.isKinematic = true; handTarget.handRigidbody.isKinematic = true;
handTarget.handRigidbody.interpolation = RigidbodyInterpolation.None; handTarget.handRigidbody.interpolation = RigidbodyInterpolation.None;

View File

@ -27,7 +27,7 @@ namespace Passer.Humanoid {
#if hFACE #if hFACE
if (headTarget.neck.target.confidence.rotation < 0.2F && headTarget.head.target.confidence.rotation < 0.2F && if (headTarget.neck.target.confidence.rotation < 0.2F && headTarget.head.target.confidence.rotation < 0.2F &&
headTarget.face.leftEye.target.confidence.rotation > 0.2F && headTarget.headAnimator.headAnimation == true) { headTarget.face.leftEye.target.confidence.rotation > 0.2F) {
UpdateHeadBonesFromGazeDirection(headTarget); UpdateHeadBonesFromGazeDirection(headTarget);
} }

View File

@ -31,7 +31,7 @@ namespace Passer.Humanoid {
} }
} }
protected void FullInverseKinematics(FootTarget footTarget) { private void FullInverseKinematics(FootTarget footTarget) {
//Debug.Log("FullInverseKinematics"); //Debug.Log("FullInverseKinematics");
if (footTarget.foot.target.transform == null) if (footTarget.foot.target.transform == null)
@ -55,7 +55,7 @@ namespace Passer.Humanoid {
PlaceFootOnLowerLeg(footTarget, lowerLegRotation); PlaceFootOnLowerLeg(footTarget, lowerLegRotation);
} }
protected void FullForwardKinematics(FootTarget footTarget) { private void FullForwardKinematics(FootTarget footTarget) {
//Debug.Log("FullForwardKinematics"); //Debug.Log("FullForwardKinematics");
footTarget.upperLeg.SetBoneRotation(footTarget.upperLeg.target.transform.rotation); footTarget.upperLeg.SetBoneRotation(footTarget.upperLeg.target.transform.rotation);
footTarget.lowerLeg.SetBoneRotation(footTarget.lowerLeg.target.transform.rotation); footTarget.lowerLeg.SetBoneRotation(footTarget.lowerLeg.target.transform.rotation);
@ -82,7 +82,7 @@ namespace Passer.Humanoid {
#region Upper Leg #region Upper Leg
protected Quaternion NaturalUpperLegOrientation(FootTarget footTarget, Vector3 footPosition) { private Quaternion NaturalUpperLegOrientation(FootTarget footTarget, Vector3 footPosition) {
Quaternion oldUpperLegRotation = footTarget.upperLeg.bone.transform.rotation * footTarget.upperLeg.bone.toTargetRotation; 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); 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); //upperLegRotation = LimitRotationSpeed(oldUpperLegRotation, upperLegRotation);
@ -130,8 +130,7 @@ namespace Passer.Humanoid {
#endregion #endregion
#region Lower Leg #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); float lowerLegAngle = CalculateKneeAngle(footTarget.upperLeg.bone.transform.position, footPosition, footTarget.upperLeg.bone.length, footTarget.lowerLeg.bone.length);
if (footTarget.lowerLeg.bone.jointLimitations) if (footTarget.lowerLeg.bone.jointLimitations)
@ -164,13 +163,12 @@ namespace Passer.Humanoid {
kneeAngle = 180; kneeAngle = 180;
return 180 - kneeAngle; return 180 - kneeAngle;
} }
#endregion #endregion
#region Foot #region Foot
// Calculate the foot position taking body limitations into account // Calculate the foot position taking body limitations into account
protected Vector3 NaturalFootPosition(FootTarget footTarget) { private Vector3 NaturalFootPosition(FootTarget footTarget) {
if (footTarget.ground == null || !footTarget.physics) if (footTarget.ground == null || !footTarget.physics)
return footTarget.foot.target.transform.position; return footTarget.foot.target.transform.position;
else { else {
@ -179,7 +177,7 @@ namespace Passer.Humanoid {
} }
// Calculate the foot orientation taking body limitation into account // Calculate the foot orientation taking body limitation into account
protected Quaternion NaturalFootOrientation(FootTarget footTarget) { private Quaternion NaturalFootOrientation(FootTarget footTarget) {
Quaternion footOrientation = DetermineFootOrientation(footTarget); Quaternion footOrientation = DetermineFootOrientation(footTarget);
if (footTarget.foot.bone.jointLimitations) if (footTarget.foot.bone.jointLimitations)
footOrientation = LimitAngle(footTarget.foot, ref lastLocalFootRotation, footOrientation); footOrientation = LimitAngle(footTarget.foot, ref lastLocalFootRotation, footOrientation);
@ -227,15 +225,14 @@ namespace Passer.Humanoid {
return footPosition; return footPosition;
} }
public static void PlaceFootOnLowerLeg(FootTarget footTarget, Quaternion lowerLegRotation) { private 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; footTarget.foot.bone.transform.position = footTarget.lowerLeg.bone.transform.position + lowerLegRotation * -footTarget.humanoid.up * footTarget.lowerLeg.bone.length;
} }
#endregion #endregion
#region Toes #region Toes
private Quaternion NaturalToesOrientation(FootTarget footTarget) {
protected Quaternion NaturalToesOrientation(FootTarget footTarget) {
Quaternion footRotation = footTarget.foot.bone.transform.rotation * footTarget.foot.bone.toTargetRotation; Quaternion footRotation = footTarget.foot.bone.transform.rotation * footTarget.foot.bone.toTargetRotation;
if (footTarget.ground != null) { if (footTarget.ground != null) {
return Quaternion.LookRotation(footTarget.groundNormal, footRotation * Vector3.back) * Quaternion.Euler(90, 0, 0); return Quaternion.LookRotation(footTarget.groundNormal, footRotation * Vector3.back) * Quaternion.Euler(90, 0, 0);
@ -244,7 +241,6 @@ namespace Passer.Humanoid {
return footRotation; return footRotation;
} }
} }
#endregion #endregion
private static float Square(float x) { private static float Square(float x) {

View File

@ -287,7 +287,7 @@ namespace Passer.Humanoid {
return; return;
} }
#else #else
if (!string.IsNullOrEmpty(msg.possessionLocation)) { if (msg.possessionLocation != null) {
Debug.Log("Need to download instantiate avatar possession from " + msg.possessionLocation); Debug.Log("Need to download instantiate avatar possession from " + msg.possessionLocation);
remoteHumanoid.physics = msg.physics; remoteHumanoid.physics = msg.physics;
@ -1103,17 +1103,9 @@ namespace Passer.Humanoid {
} }
HumanoidTarget target = GetTarget(humanoid, targetPose.boneId); HumanoidTarget target = GetTarget(humanoid, targetPose.boneId);
if (target != null) { 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.animator.enabled = false;
//target.EnableAnimator(false); //target.EnableAnimator(false);
}
}
if (targetPose.boneId == Tracking.Bone.LeftHand || targetPose.boneId == Tracking.Bone.RightHand) if (targetPose.boneId == Tracking.Bone.LeftHand || targetPose.boneId == Tracking.Bone.RightHand)
ReceiveHand((HandTarget)target, (HumanoidHandPose)targetPose); ReceiveHand((HandTarget)target, (HumanoidHandPose)targetPose);
@ -1718,11 +1710,7 @@ namespace Passer.Humanoid {
public static List<HumanoidControl> FindLocalHumanoids() { public static List<HumanoidControl> FindLocalHumanoids() {
List<HumanoidControl> humanoidList = new List<HumanoidControl>(); 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>(); HumanoidControl[] foundHumanoids = UnityEngine.Object.FindObjectsOfType<HumanoidControl>();
#endif
for (int i = 0; i < foundHumanoids.Length; i++) { for (int i = 0; i < foundHumanoids.Length; i++) {
if (!foundHumanoids[i].isRemote) { if (!foundHumanoids[i].isRemote) {
humanoidList.Add(foundHumanoids[i]); humanoidList.Add(foundHumanoids[i]);
@ -1732,11 +1720,7 @@ namespace Passer.Humanoid {
} }
public static IHumanoidNetworking GetLocalHumanoidNetworking() { 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>(); HumanoidPlayer[] humanoidNetworkings = UnityEngine.Object.FindObjectsOfType<HumanoidPlayer>();
#endif
foreach (IHumanoidNetworking humanoidNetworking in humanoidNetworkings) { foreach (IHumanoidNetworking humanoidNetworking in humanoidNetworkings) {
if (humanoidNetworking.isLocal) if (humanoidNetworking.isLocal)
return humanoidNetworking; return humanoidNetworking;

View File

@ -0,0 +1,7 @@
using UnityEngine;
namespace Passer.Humanoid {
public partial class HumanoidPlayerPunVoice : MonoBehaviour {
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 69a31162e39169c4fad112f52654bd40 guid: c48e8d9c90f89154daf3a86de9a5f2ad
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@ -6,19 +6,18 @@ namespace Passer {
protected NetworkingStarter networkingStarter; protected NetworkingStarter networkingStarter;
protected UnityEngine.UI.Text textcomponent; protected UnityEngine.UI.Text textcomponent;
protected void Start() { void Start() {
#if UNITY_6000_0_OR_NEWER
networkingStarter = Object.FindAnyObjectByType<NetworkingStarter>();
#else
networkingStarter = FindObjectOfType<NetworkingStarter>(); networkingStarter = FindObjectOfType<NetworkingStarter>();
#endif
textcomponent = GetComponent<UnityEngine.UI.Text>(); textcomponent = GetComponent<UnityEngine.UI.Text>();
} }
protected void Update() { void Update() {
#if hNW_UNET || hNW_PHOTON #if hNW_UNET || hNW_PHOTON
if (networkingStarter == null) if (networkingStarter == null)
return; return;
//if (textcomponent != null)
// textcomponent.text = networkingStarter.networkingStatus.ToString();
#endif #endif
} }
} }

View File

@ -1,670 +0,0 @@
#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
}

View File

@ -1,72 +0,0 @@
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
}
}

View File

@ -1,64 +0,0 @@
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.
///
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 25694d80cf4ce2940b87374eb5c2d879
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,97 +0,0 @@
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
}

View File

@ -1,12 +0,0 @@
fileFormatVersion: 2
guid: bbe6fd67c1c770e478d9cb8eef19b594
timeCreated: 1466884930
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,15 @@
using UnityEngine;
using System.Collections;
public class FootPhysics : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}

View File

@ -1,6 +1,6 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: b2b89683096330a4eb3810fdaeb79fb6 guid: 8485b8871c8f9cf4e870d0ef4ab949cd
timeCreated: 1504014033 timeCreated: 1483383200
licenseType: Free licenseType: Free
MonoImporter: MonoImporter:
serializedVersion: 2 serializedVersion: 2

View File

@ -23,7 +23,7 @@ namespace Passer.Humanoid {
} }
[HideInInspector] [HideInInspector]
public Rigidbody handRigidbody; protected Rigidbody handRigidbody;
protected virtual void Initialize() { protected virtual void Initialize() {
if (handTarget == null) if (handTarget == null)
@ -186,7 +186,7 @@ namespace Passer.Humanoid {
#region Force #region Force
protected virtual Vector3 CalculateForce() { protected Vector3 CalculateForce() {
/* /*
//Vector3 locationDifference = handTarget.stretchlessTarget.position - handTarget.handRigidbody.position; //Vector3 locationDifference = handTarget.stretchlessTarget.position - handTarget.handRigidbody.position;
//Debug.DrawLine(handTarget.stretchlessTarget.position, handTarget.handRigidbody.position); //Debug.DrawLine(handTarget.stretchlessTarget.position, handTarget.handRigidbody.position);
@ -204,17 +204,10 @@ namespace Passer.Humanoid {
return force; 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 const float damping = 12;
protected float lastDistanceTime; private float lastDistanceTime;
protected Vector3 lastDistanceToTarget; private Vector3 lastDistanceToTarget;
protected virtual Vector3 CalculateForceDamper() { private Vector3 CalculateForceDamper() {
Vector3 distanceToTarget = handTarget.hand.bone.transform.position - handTarget.hand.target.transform.position; Vector3 distanceToTarget = handTarget.hand.bone.transform.position - handTarget.hand.target.transform.position;
float deltaTime = Time.fixedTime - lastDistanceTime; float deltaTime = Time.fixedTime - lastDistanceTime;
@ -227,11 +220,7 @@ namespace Passer.Humanoid {
//Compensate for absolute rigidbody speed (specifically when on a moving platform) //Compensate for absolute rigidbody speed (specifically when on a moving platform)
if (handRigidbody != null) { if (handRigidbody != null) {
#if UNITY_6000_0_OR_NEWER
Vector3 residualVelocity = handRigidbody.linearVelocity - velocityTowardsTarget;
#else
Vector3 residualVelocity = handRigidbody.velocity - velocityTowardsTarget; Vector3 residualVelocity = handRigidbody.velocity - velocityTowardsTarget;
#endif
damper += residualVelocity * 10; damper += residualVelocity * 10;
} }
} }
@ -241,7 +230,7 @@ namespace Passer.Humanoid {
return damper; return damper;
} }
protected virtual void ApplyForce(Vector3 force) { protected void ApplyForce(Vector3 force) {
if (float.IsNaN(force.magnitude)) if (float.IsNaN(force.magnitude))
return; return;
@ -270,7 +259,7 @@ namespace Passer.Humanoid {
#endif #endif
} }
protected virtual void ApplyForceAtPosition(Vector3 force, Vector3 position) { protected void ApplyForceAtPosition(Vector3 force, Vector3 position) {
if (float.IsNaN(force.magnitude)) if (float.IsNaN(force.magnitude))
return; return;
@ -284,7 +273,7 @@ namespace Passer.Humanoid {
#region Torque #region Torque
protected virtual Vector3 CalculateTorque() { protected Vector3 CalculateTorque() {
Quaternion sollRotation = handTarget.hand.target.transform.rotation * handTarget.hand.target.toBoneRotation; Quaternion sollRotation = handTarget.hand.target.transform.rotation * handTarget.hand.target.toBoneRotation;
Quaternion istRotation = handTarget.hand.bone.transform.rotation; Quaternion istRotation = handTarget.hand.bone.transform.rotation;
Quaternion dRot = sollRotation * Quaternion.Inverse(istRotation); Quaternion dRot = sollRotation * Quaternion.Inverse(istRotation);
@ -299,7 +288,7 @@ namespace Passer.Humanoid {
return torque; return torque;
} }
protected virtual Vector3 CalculateWristTorque() { protected Vector3 CalculateWristTorque() {
//Vector3 wristTension = target.GetWristTension(); //Vector3 wristTension = target.GetWristTension();
// Not stable // Not stable
@ -315,7 +304,7 @@ namespace Passer.Humanoid {
ApplyTorqueAtPosition(torque, handTarget.hand.bone.transform.position); ApplyTorqueAtPosition(torque, handTarget.hand.bone.transform.position);
} }
protected virtual void ApplyTorqueAtPosition(Vector3 torque, Vector3 posToApply) { protected void ApplyTorqueAtPosition(Vector3 torque, Vector3 posToApply) {
if (float.IsNaN(torque.magnitude)) if (float.IsNaN(torque.magnitude))
return; return;
@ -364,7 +353,7 @@ namespace Passer.Humanoid {
} }
public PhysicsMode mode = PhysicsMode.HybridKinematic; public PhysicsMode mode = PhysicsMode.HybridKinematic;
protected bool colliding; private bool colliding;
public bool hasCollided = false; public bool hasCollided = false;
public Vector3 contactPoint; public Vector3 contactPoint;
@ -425,7 +414,7 @@ namespace Passer.Humanoid {
colliding = false; colliding = false;
} }
public virtual void UpdateRigidbody() { public void UpdateRigidbody() {
if (handRigidbody == null) { if (handRigidbody == null) {
UpdateGrabbedMechanicalJoint(); UpdateGrabbedMechanicalJoint();
return; return;
@ -452,7 +441,7 @@ namespace Passer.Humanoid {
UpdateNonKinematicRigidbody(); UpdateNonKinematicRigidbody();
} }
protected void UpdateGrabbedMechanicalJoint() { private void UpdateGrabbedMechanicalJoint() {
Rigidbody grabbedRigidbody = handTarget.hand.bone.transform.GetComponentInParent<Rigidbody>(); Rigidbody grabbedRigidbody = handTarget.hand.bone.transform.GetComponentInParent<Rigidbody>();
if (grabbedRigidbody == null) if (grabbedRigidbody == null)
return; return;
@ -474,7 +463,7 @@ namespace Passer.Humanoid {
grabbedRigidbody.transform.rotation = grabbedRigidbody.transform.rotation * correctionRotation; grabbedRigidbody.transform.rotation = grabbedRigidbody.transform.rotation * correctionRotation;
} }
protected void UpdateKinematicRigidbody() { private void UpdateKinematicRigidbody() {
if (mode == PhysicsMode.NonKinematic || if (mode == PhysicsMode.NonKinematic ||
mode == PhysicsMode.HybridKinematic && ( mode == PhysicsMode.HybridKinematic && (
handRigidbody.mass > HybridPhysics.kinematicMass || handRigidbody.mass > HybridPhysics.kinematicMass ||
@ -556,11 +545,7 @@ namespace Passer.Humanoid {
Vector3 velocityTarget = (positionDelta * velocityMagic) * Time.fixedDeltaTime; Vector3 velocityTarget = (positionDelta * velocityMagic) * Time.fixedDeltaTime;
if (float.IsNaN(velocityTarget.x) == false) 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); handRigidbody.velocity = Vector3.MoveTowards(handRigidbody.velocity, velocityTarget, MaxVelocityChange);
#endif
rotationDelta.ToAngleAxis(out angle, out axis); rotationDelta.ToAngleAxis(out angle, out axis);
@ -685,7 +670,7 @@ namespace Passer.Humanoid {
handTarget.grabbedObject.SendMessage("OnCollisionEnter", collision, SendMessageOptions.DontRequireReceiver); handTarget.grabbedObject.SendMessage("OnCollisionEnter", collision, SendMessageOptions.DontRequireReceiver);
} }
public virtual void OnCollisionStay(Collision collision) { public void OnCollisionStay(Collision collision) {
if (collision.rigidbody != null && collision.rigidbody.gameObject == handTarget.grabbedObject) if (collision.rigidbody != null && collision.rigidbody.gameObject == handTarget.grabbedObject)
// Don't collide with the things you are holding // Don't collide with the things you are holding
return; return;

View File

@ -13,17 +13,17 @@ namespace Passer.Humanoid {
/// This is the HandTarget of the hand to which the socket is attached /// This is the HandTarget of the hand to which the socket is attached
public HandTarget handTarget; public HandTarget handTarget;
//protected override void MoveHandleToSocket(Transform socketTransform, Handle handle) { protected override void MoveHandleToSocket(Transform socketTransform, Handle handle) {
// DebugLog("MoveHandleToHand"); DebugLog("MoveHandleToHand");
// Transform handleTransform = handle.GetComponent<Transform>(); Transform handleTransform = handle.GetComponent<Transform>();
// Rigidbody handleRigidbody = handle.GetComponentInParent<Rigidbody>(); Rigidbody handleRigidbody = handle.GetComponentInParent<Rigidbody>();
// if (handleRigidbody != null) if (handleRigidbody != null)
// handleTransform = handleRigidbody.transform; handleTransform = handleRigidbody.transform;
// handleTransform.rotation = handle.RotationTo(socketTransform.rotation) * handleTransform.rotation; handleTransform.rotation = handle.RotationTo(socketTransform.rotation) * handleTransform.rotation;
// handleTransform.position += handle.TranslationTo(socketTransform.position); handleTransform.position += handle.TranslationTo(socketTransform.position);
//} }
protected override void MoveSocketToHandle(Transform socketTransform, Handle handle) { protected override void MoveSocketToHandle(Transform socketTransform, Handle handle) {
DebugLog("MoveHandToHandle"); DebugLog("MoveHandToHandle");
@ -155,7 +155,7 @@ namespace Passer.Humanoid {
DestroyedJoints destroyedJoints = objRigidbody.GetComponent<DestroyedJoints>(); DestroyedJoints destroyedJoints = objRigidbody.GetComponent<DestroyedJoints>();
// Check if we are grabbing a hand // Check if we are grabbing a hand
BasicHandPhysics handPhysics = objRigidbody.GetComponentInParent<BasicHandPhysics>(); BasicHandPhysics handPhysics = objRigidbody.GetComponent<BasicHandPhysics>();
if (handPhysics != null) { // We are grabbing a hand if (handPhysics != null) { // We are grabbing a hand
if (thisRigidbody == null) { if (thisRigidbody == null) {
DebugLog("Cannot attach to hand because this handRigidbody is not present"); DebugLog("Cannot attach to hand because this handRigidbody is not present");

View File

@ -15,13 +15,8 @@ namespace Passer {
public RigidbodyData(Rigidbody rb) { public RigidbodyData(Rigidbody rb) {
mass = rb.mass; mass = rb.mass;
#if UNITY_6000_0_OR_NEWER
drag = rb.linearDamping;
angularDrag = rb.angularDamping;
#else
drag = rb.drag; drag = rb.drag;
angularDrag = rb.angularDrag; angularDrag = rb.angularDrag;
#endif
useGravity = rb.useGravity; useGravity = rb.useGravity;
isKinematic = rb.isKinematic; isKinematic = rb.isKinematic;
interpolation = rb.interpolation; interpolation = rb.interpolation;
@ -33,13 +28,8 @@ namespace Passer {
public void CopyToRigidbody(Rigidbody rb) { public void CopyToRigidbody(Rigidbody rb) {
rb.mass = mass; rb.mass = mass;
#if UNITY_6000_0_OR_NEWER
rb.linearDamping = drag;
rb.angularDamping = angularDrag;
#else
rb.drag = drag; rb.drag = drag;
rb.angularDrag = angularDrag; rb.angularDrag = angularDrag;
#endif
rb.useGravity = useGravity; rb.useGravity = useGravity;
rb.isKinematic = isKinematic; rb.isKinematic = isKinematic;
rb.interpolation = interpolation; rb.interpolation = interpolation;

View File

@ -40,18 +40,17 @@ namespace Passer.Humanoid {
HumanoidTarget.TargetedBone referenceBone = humanoid.GetBone(referenceBoneRef.boneId); HumanoidTarget.TargetedBone referenceBone = humanoid.GetBone(referenceBoneRef.boneId);
if (referenceBoneRef.boneId != Bone.None && referenceBone.target.transform != null) { if (referenceBoneRef.boneId != Bone.None && referenceBone.target.transform != null) {
referencePosition = referenceBone.target.transform.position; referencePosition = referenceBone.target.transform.position;
referenceRotation = referenceBone.target.transform.rotation; //referenceBone.bone.targetRotation; referenceRotation = referenceBone.bone.targetRotation;
referenceScale = referenceBone.target.transform.lossyScale; referenceScale = referenceBone.target.transform.lossyScale;
} }
else { else {
referencePosition = targetedBone.TargetBasePosition(); // humanoid.transform.position; referencePosition = humanoid.transform.position;
referenceRotation = humanoid.transform.rotation; referenceRotation = humanoid.transform.rotation;
referenceScale = humanoid.transform.lossyScale; referenceScale = humanoid.transform.lossyScale;
} }
if (setTranslation) 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) if (setRotation)
targetedBone.target.transform.rotation = Quaternion.Slerp(targetedBone.TargetBaseRotation(), referenceRotation * rotation, value); targetedBone.target.transform.rotation = Quaternion.Slerp(targetedBone.TargetBaseRotation(), referenceRotation * rotation, value);
if (setScale) if (setScale)

View File

@ -114,7 +114,6 @@ namespace Passer.Humanoid {
public void ShowPose(HumanoidControl humanoid, Side showSide) { public void ShowPose(HumanoidControl humanoid, Side showSide) {
detectedPoseIx = -1; detectedPoseIx = -1;
float bestScore = -1; float bestScore = -1;
detectedPose = null;
if (poseMode == PoseMode.Set) if (poseMode == PoseMode.Set)
ResetAffectedBones(humanoid, showSide); ResetAffectedBones(humanoid, showSide);

View File

@ -1,7 +1,8 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 3cec17721dc9fb0499bab2210c9bf0ac guid: 94cc904628763c548944b198ccc94346
PrefabImporter: timeCreated: 1486644658
externalObjects: {} licenseType: Free
NativeFormatImporter:
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:

View File

@ -1,8 +1,9 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: df1bff1867e6b5e42a3d0019e53e5550 guid: cc84ac7c95c473c44b97c107602087b7
folderAsset: yes folderAsset: yes
timeCreated: 1486643266
licenseType: Free
DefaultImporter: DefaultImporter:
externalObjects: {}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:

View File

@ -2,24 +2,19 @@
%TAG !u! tag:unity3d.com,2011: %TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000 --- !u!21 &2100000
Material: Material:
serializedVersion: 8 serializedVersion: 6
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_PrefabParentObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInternal: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_Name: Material
m_Name: 292
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_Parent: {fileID: 0} m_ShaderKeywords: _EMISSION
m_ModifiedSerializedProperties: 0 m_LightmapFlags: 1
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0 m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0 m_DoubleSidedGI: 0
m_CustomRenderQueue: -1 m_CustomRenderQueue: -1
stringTagMap: {} stringTagMap: {}
disabledShaderPasses: [] disabledShaderPasses: []
m_LockedProperties:
m_SavedProperties: m_SavedProperties:
serializedVersion: 3 serializedVersion: 3
m_TexEnvs: m_TexEnvs:
@ -59,14 +54,13 @@ Material:
m_Texture: {fileID: 0} m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1} m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0} m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats: m_Floats:
- _BumpScale: 1 - _BumpScale: 1
- _Cutoff: 0.5 - _Cutoff: 0.5
- _DetailNormalMapScale: 1 - _DetailNormalMapScale: 1
- _DstBlend: 0 - _DstBlend: 0
- _GlossMapScale: 1 - _GlossMapScale: 1
- _Glossiness: 0 - _Glossiness: 0.5
- _GlossyReflections: 1 - _GlossyReflections: 1
- _Metallic: 0 - _Metallic: 0
- _Mode: 0 - _Mode: 0
@ -80,4 +74,3 @@ Material:
m_Colors: m_Colors:
- _Color: {r: 0.8, g: 0.8, b: 0.8, a: 1} - _Color: {r: 0.8, g: 0.8, b: 0.8, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1} - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f288e74f24dec3949aed8e4f550c4b83
timeCreated: 1486643266
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +1,9 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 6abcb3631639c01478d992ecbd8dc39a guid: 02da7ec8c993b874381f34377f818316
folderAsset: yes folderAsset: yes
timeCreated: 1486643408
licenseType: Free
DefaultImporter: DefaultImporter:
externalObjects: {}
userData: userData:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:

View File

@ -649,11 +649,7 @@ namespace Passer.Humanoid {
private HumanoidControl GetHumanoid() { private HumanoidControl GetHumanoid() {
// This does not work for prefabs // This does not work for prefabs
#if UNITY_6000_0_OR_NEWER
HumanoidControl[] humanoids = FindObjectsByType<HumanoidControl>(FindObjectsSortMode.None);
#else
HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>(); HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>();
#endif
for (int i = 0; i < humanoids.Length; i++) { for (int i = 0; i < humanoids.Length; i++) {
if ((humanoids[i].leftFootTarget != null && humanoids[i].leftFootTarget.transform == this.transform) || if ((humanoids[i].leftFootTarget != null && humanoids[i].leftFootTarget.transform == this.transform) ||
@ -833,7 +829,7 @@ namespace Passer.Humanoid {
toes.MatchTargetToAvatar(); toes.MatchTargetToAvatar();
} }
#endregion #endregion
#region Update #region Update

View File

@ -650,7 +650,7 @@ namespace Passer.Humanoid {
#endregion #endregion
protected void InitSubTargets() { private void InitSubTargets() {
//foreach (TargetedBone subTarget in subTargets) //foreach (TargetedBone subTarget in subTargets)
// subTarget.Init(); // subTarget.Init();
shoulder.Init(); shoulder.Init();
@ -911,17 +911,6 @@ namespace Passer.Humanoid {
public bool twoHandedGrab = false; public bool twoHandedGrab = false;
public Vector3 targetToSecondaryHandle; 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() { public bool GrabbedStaticObject() {
if (grabbedObject != null && grabbedRigidbody && grabbedKinematicRigidbody) if (grabbedObject != null && grabbedRigidbody && grabbedKinematicRigidbody)
return true; return true;
@ -1163,11 +1152,7 @@ namespace Passer.Humanoid {
private HumanoidControl GetHumanoid() { private HumanoidControl GetHumanoid() {
// This does not work for prefabs // This does not work for prefabs
#if UNITY_6000_0_OR_NEWER
HumanoidControl[] humanoids = FindObjectsByType<HumanoidControl>(FindObjectsSortMode.None);
#else
HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>(); HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>();
#endif
for (int i = 0; i < humanoids.Length; i++) { for (int i = 0; i < humanoids.Length; i++) {
if ((humanoids[i].leftHandTarget != null && humanoids[i].leftHandTarget.transform == this.transform) || if ((humanoids[i].leftHandTarget != null && humanoids[i].leftHandTarget.transform == this.transform) ||
@ -1199,13 +1184,8 @@ namespace Passer.Humanoid {
handRigidbody = hand.bone.transform.gameObject.AddComponent<Rigidbody>(); handRigidbody = hand.bone.transform.gameObject.AddComponent<Rigidbody>();
} }
handRigidbody.mass = 1; handRigidbody.mass = 1;
#if UNITY_6000_0_OR_NEWER
handRigidbody.linearDamping = 0;
handRigidbody.angularDamping = 10;
#else
handRigidbody.drag = 0; handRigidbody.drag = 0;
handRigidbody.angularDrag = 10; handRigidbody.angularDrag = 10;
#endif
handRigidbody.useGravity = false; handRigidbody.useGravity = false;
handRigidbody.isKinematic = true; handRigidbody.isKinematic = true;
handRigidbody.interpolation = RigidbodyInterpolation.None; handRigidbody.interpolation = RigidbodyInterpolation.None;
@ -1762,7 +1742,7 @@ namespace Passer.Humanoid {
#region Colliders #region Colliders
protected void CheckColliders() { private void CheckColliders() {
if (hand.bone.transform == null) if (hand.bone.transform == null)
return; return;

View File

@ -560,7 +560,6 @@ namespace Passer.Humanoid {
neck.RetrieveBones(humanoid); neck.RetrieveBones(humanoid);
head.RetrieveBones(humanoid); head.RetrieveBones(humanoid);
#if hFACE #if hFACE
face.InitComponent();
face.RetrieveBones(this); face.RetrieveBones(this);
#endif #endif
} }
@ -750,11 +749,7 @@ namespace Passer.Humanoid {
private HumanoidControl GetHumanoid() { private HumanoidControl GetHumanoid() {
// This does not work for prefabs // This does not work for prefabs
#if UNITY_6000_0_OR_NEWER
HumanoidControl[] humanoids = FindObjectsByType<HumanoidControl>(FindObjectsSortMode.None);
#else
HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>(); HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>();
#endif
for (int i = 0; i < humanoids.Length; i++) { for (int i = 0; i < humanoids.Length; i++) {
if (humanoids[i].headTarget != null && humanoids[i].headTarget.transform == this.transform) if (humanoids[i].headTarget != null && humanoids[i].headTarget.transform == this.transform)
@ -804,6 +799,9 @@ namespace Passer.Humanoid {
if (humanoid == null) if (humanoid == null)
return; return;
#if hFACE
face.InitComponent();
#endif
} }
public override void StartTarget() { public override void StartTarget() {
@ -880,7 +878,7 @@ namespace Passer.Humanoid {
#endif #endif
} }
#endregion #endregion
#region Update #region Update
@ -1066,7 +1064,7 @@ namespace Passer.Humanoid {
#region Tools #region Tools
/// <summary>Gets the eye position in world coordinates</summary> /// <summary>Gets the eye position in world coordinates</summary>
public virtual Vector3 GetEyePosition() { public Vector3 GetEyePosition() {
if (Application.isPlaying && gameObject != null) { if (Application.isPlaying && gameObject != null) {
Camera camera = gameObject.GetComponentInChildren<Camera>(); Camera camera = gameObject.GetComponentInChildren<Camera>();
if (camera != null) if (camera != null)
@ -1222,6 +1220,15 @@ namespace Passer.Humanoid {
} }
} }
public void DisableVR() {
UnityEngine.XR.XRSettings.LoadDeviceByName("None");
}
public void EnableVR() {
// Just oculus for now
UnityEngine.XR.XRSettings.LoadDeviceByName("Oculus");
}
#endregion #endregion
} }
} }

View File

@ -47,7 +47,6 @@ namespace Passer.Humanoid {
hips = new TargetedHipsBone(this); hips = new TargetedHipsBone(this);
} }
public bool simpleSpineIK => newSpineIK;
public bool newSpineIK = false; public bool newSpineIK = false;
public TorsoMovements torsoMovements = new TorsoMovements(); public TorsoMovements torsoMovements = new TorsoMovements();
@ -89,7 +88,7 @@ namespace Passer.Humanoid {
public CustomTorso custom = new CustomTorso(); public CustomTorso custom = new CustomTorso();
#endif #endif
protected TorsoSensor[] sensors; private TorsoSensor[] sensors;
public override void InitSensors() { public override void InitSensors() {
@ -461,11 +460,7 @@ namespace Passer.Humanoid {
private HumanoidControl GetHumanoid() { private HumanoidControl GetHumanoid() {
// This does not work for prefabs // This does not work for prefabs
#if UNITY_6000_0_OR_NEWER
HumanoidControl[] humanoids = FindObjectsByType<HumanoidControl>(FindObjectsSortMode.None);
#else
HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>(); HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>();
#endif
for (int i = 0; i < humanoids.Length; i++) { for (int i = 0; i < humanoids.Length; i++) {
if (humanoids[i].hipsTarget != null && humanoids[i].hipsTarget.transform == this.transform) if (humanoids[i].hipsTarget != null && humanoids[i].hipsTarget.transform == this.transform)
@ -619,7 +614,7 @@ namespace Passer.Humanoid {
} }
#endregion #endregion
#region Update #region Update

View File

@ -17,7 +17,6 @@ namespace Passer {
/// </summary> /// </summary>
public abstract class Target : MonoBehaviour { public abstract class Target : MonoBehaviour {
[SerializeField]
protected bool _showRealObjects = true; protected bool _showRealObjects = true;
/// <summary> /// <summary>
/// show the target meshes /// show the target meshes

View File

@ -59,7 +59,7 @@ namespace Passer.Humanoid {
/// as the third person avatar. /// as the third person avatar.
public Animator[] tpAvatars = new Animator[0]; public Animator[] tpAvatars = new Animator[0];
protected HumanoidControl humanoid; private HumanoidControl humanoid;
protected virtual void Start() { protected virtual void Start() {
humanoid = GetComponent<HumanoidControl>(); humanoid = GetComponent<HumanoidControl>();

View File

@ -1,9 +1,7 @@
using System.Collections; using System.Collections;
using UnityEngine; using UnityEngine;
namespace Passer { public class FlashLight : MonoBehaviour {
public class FlashLight : MonoBehaviour {
protected Light thisLight; protected Light thisLight;
@ -32,5 +30,4 @@ namespace Passer {
yield return new WaitForSeconds(duration); yield return new WaitForSeconds(duration);
light.enabled = false; light.enabled = false;
} }
}
} }

View File

@ -1,12 +1,8 @@
using UnityEngine; using UnityEngine;
namespace Passer { public class Hit : MonoBehaviour {
public class Hit : MonoBehaviour {
public void HitMe() { public void HitMe() {
Debug.Log("AU!"); Debug.Log("AU!");
} }
}
} }

View File

@ -51,11 +51,7 @@ namespace Passer {
/// </summary> /// </summary>
/// <returns>The found humanoid, null if no local humanoid has been found</returns> /// <returns>The found humanoid, null if no local humanoid has been found</returns>
protected HumanoidControl FindHumanoid() { protected HumanoidControl FindHumanoid() {
#if UNITY_6000_0_OR_NEWER
HumanoidControl[] humanoids = FindObjectsByType<HumanoidControl>(FindObjectsSortMode.None);
#else
HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>(); HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>();
#endif
for (int i = 0; i < humanoids.Length; i++) { for (int i = 0; i < humanoids.Length; i++) {
if (humanoids[i].isRemote == false) if (humanoids[i].isRemote == false)
return humanoids[i]; return humanoids[i];

View File

@ -1,8 +1,6 @@
using UnityEngine; using UnityEngine;
namespace Passer { public class Redrop : MonoBehaviour {
public class Redrop : MonoBehaviour {
// Script which is to be replaced by CollisionEventHandler // Script which is to be replaced by CollisionEventHandler
@ -12,18 +10,18 @@ namespace Passer {
private Vector3 startPosition; private Vector3 startPosition;
private Quaternion startRotation; private Quaternion startRotation;
protected void Start() { void Start() {
startPosition = transform.position; startPosition = transform.position;
startRotation = transform.rotation; startRotation = transform.rotation;
} }
protected void Update() { void Update() {
if (groundCollider == null && transform.position.y < 0) { if (groundCollider == null && transform.position.y < 0) {
MoveToStart(); MoveToStart();
} }
} }
protected void OnCollisionEnter(Collision collision) { private void OnCollisionEnter(Collision collision) {
if (collision.collider == groundCollider) { if (collision.collider == groundCollider) {
MoveToStart(); MoveToStart();
} }
@ -34,14 +32,8 @@ namespace Passer {
if (thisRigidbody != null) { if (thisRigidbody != null) {
thisRigidbody.MovePosition(new Vector3(startPosition.x, startPosition.y + 0.1F, startPosition.z)); thisRigidbody.MovePosition(new Vector3(startPosition.x, startPosition.y + 0.1F, startPosition.z));
thisRigidbody.MoveRotation(startRotation); thisRigidbody.MoveRotation(startRotation);
#if UNITY_6000_0_OR_NEWER
thisRigidbody.linearVelocity = Vector3.zero;
#else
thisRigidbody.velocity = Vector3.zero; thisRigidbody.velocity = Vector3.zero;
#endif
thisRigidbody.angularVelocity = Vector3.zero; thisRigidbody.angularVelocity = Vector3.zero;
} }
} }
}
} }

View File

@ -4,10 +4,9 @@ using UnityEngine.SceneManagement;
using UnityEditor; using UnityEditor;
using UnityEditor.SceneManagement; using UnityEditor.SceneManagement;
namespace Passer {
[InitializeOnLoad] [InitializeOnLoad]
public class SceneLoader { public class SceneLoader {
static SceneLoader() { static SceneLoader() {
EditorSceneManager.sceneOpened += SceneOpened; EditorSceneManager.sceneOpened += SceneOpened;
} }
@ -15,31 +14,21 @@ namespace Passer {
private static void SceneOpened(Scene scene, OpenSceneMode mode) { private static void SceneOpened(Scene scene, OpenSceneMode mode) {
if ((scene.name == "ObjectTable Pawn" || if ((scene.name == "ObjectTable Pawn" ||
scene.name == "ObjectTable Pawn VR" || scene.name == "ObjectTable Pawn VR" ||
scene.name == "ObjectTable Humanoid") scene.name == "ObjectTable Humanoid") &&
#if UNITY_2022_2_OR_NEWER EditorSceneManager.loadedSceneCount == 1) {
&& UnityEngine.SceneManagement.SceneManager.loadedSceneCount == 1
#else
&& EditorSceneManager.loadedSceneCount == 1
#endif
) {
//Debug.Log("Additive opening ObjectTable scene"); //Debug.Log("Additive opening ObjectTable scene");
EditorSceneManager.OpenScene("Assets/PawnControl/Demo/Environments/ObjectTable.unity", OpenSceneMode.Additive); EditorSceneManager.OpenScene("Assets/PawnControl/Demo/Environments/ObjectTable.unity", OpenSceneMode.Additive);
} }
else if ((scene.name == "ShootingRange Pawn" || else if ((scene.name == "ShootingRange Pawn" ||
scene.name == "ShootingRange Pawn VR" || scene.name == "ShootingRange Pawn VR" ||
scene.name == "ShootingRange Humanoid") scene.name == "ShootingRange Humanoid") &&
#if UNITY_2022_2_OR_NEWER EditorSceneManager.loadedSceneCount == 1) {
&& UnityEngine.SceneManagement.SceneManager.loadedSceneCount == 1
#else
&& EditorSceneManager.loadedSceneCount == 1
#endif
) {
//Debug.Log("Additive opening ShootingRange scene"); //Debug.Log("Additive opening ShootingRange scene");
EditorSceneManager.OpenScene("Assets/PawnControl/Demo/Environments/ShootingRange.unity", OpenSceneMode.Additive); EditorSceneManager.OpenScene("Assets/PawnControl/Demo/Environments/ShootingRange.unity", OpenSceneMode.Additive);
} }
} }
}
} }
#endif #endif

View File

@ -1,4 +1,6 @@
using UnityEngine; using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Passer.Humanoid { namespace Passer.Humanoid {
@ -7,11 +9,7 @@ namespace Passer.Humanoid {
protected HandTarget handTarget; protected HandTarget handTarget;
protected void Start() { protected void Start() {
#if UNITY_6000_0_OR_NEWER
HumanoidControl[] humanoids = FindObjectsByType<HumanoidControl>(FindObjectsSortMode.None);
#else
HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>(); HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>();
#endif
if (humanoids.Length != 1) if (humanoids.Length != 1)
return; return;

View File

@ -29,11 +29,7 @@ namespace Passer.Humanoid {
private void Awake() { private void Awake() {
HumanoidControl humanoidInScene = GetComponentInParent<HumanoidControl>(); HumanoidControl humanoidInScene = GetComponentInParent<HumanoidControl>();
if (humanoidInScene == null) { if (humanoidInScene == null) {
#if UNITY_6000_0_OR_NEWER
HumanoidControl[] humanoids = FindObjectsByType<HumanoidControl>(FindObjectsSortMode.None);
#else
HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>(); HumanoidControl[] humanoids = FindObjectsOfType<HumanoidControl>();
#endif
foreach (HumanoidControl humanoid in humanoids) { foreach (HumanoidControl humanoid in humanoids) {
if (humanoid.isRemote == false) if (humanoid.isRemote == false)
this.humanoid = humanoid; this.humanoid = humanoid;

View File

@ -21,11 +21,7 @@ namespace Passer {
} }
private void OnSceneLoad(Scene scene, LoadSceneMode mode) { private void OnSceneLoad(Scene scene, LoadSceneMode mode) {
#if UNITY_6000_0_OR_NEWER
Canvas[] canvases = FindObjectsByType<Canvas>(FindObjectsSortMode.None);
#else
Canvas[] canvases = FindObjectsOfType<Canvas>(); Canvas[] canvases = FindObjectsOfType<Canvas>();
#endif
foreach (Canvas canvas in canvases) foreach (Canvas canvas in canvases)
canvas.worldCamera = Camera.main; canvas.worldCamera = Camera.main;
} }

View File

@ -1,6 +1,6 @@
using UnityEngine; using UnityEngine;
namespace Passer { //namespace Passer {
public static class RigidbodyTools { public static class RigidbodyTools {
public static void DestroyGameObject(this Rigidbody rigidbody) { public static void DestroyGameObject(this Rigidbody rigidbody) {
@ -8,4 +8,4 @@ namespace Passer {
} }
} }
} //}

View File

@ -43,11 +43,7 @@ namespace Passer {
#if UNITY_EDITOR #if UNITY_EDITOR
UnityEngine.SceneManagement.SceneManager.sceneLoaded += OnSceneLoad; UnityEngine.SceneManagement.SceneManager.sceneLoaded += OnSceneLoad;
#if UNITY_6000_0_OR_NEWER
HumanoidControl humanoid = FindAnyObjectByType<HumanoidControl>();
#else
HumanoidControl humanoid = FindObjectOfType<HumanoidControl>(); HumanoidControl humanoid = FindObjectOfType<HumanoidControl>();
#endif
if (humanoid == null) { if (humanoid == null) {
string visitorScenePath = HumanoidPreferences.visitorSceneName; string visitorScenePath = HumanoidPreferences.visitorSceneName;
if (!string.IsNullOrEmpty(visitorScenePath)) { if (!string.IsNullOrEmpty(visitorScenePath)) {
@ -61,29 +57,17 @@ namespace Passer {
private void OnSceneLoad(Scene _, LoadSceneMode _1) { private void OnSceneLoad(Scene _, LoadSceneMode _1) {
#if UNITY_EDITOR #if UNITY_EDITOR
#if UNITY_6000_0_OR_NEWER
SiteNavigator[] siteNavigators = FindObjectsByType<SiteNavigator>(FindObjectsSortMode.None);
#else
SiteNavigator[] siteNavigators = FindObjectsOfType<SiteNavigator>(); SiteNavigator[] siteNavigators = FindObjectsOfType<SiteNavigator>();
#endif
foreach (SiteNavigator siteNavigator in siteNavigators) { foreach (SiteNavigator siteNavigator in siteNavigators) {
siteNavigator.startScene = null; siteNavigator.startScene = null;
siteNavigator.startSite = null; siteNavigator.startSite = null;
} }
#if UNITY_6000_0_OR_NEWER
HumanoidControl pawn = FindAnyObjectByType<HumanoidControl>();
#else
HumanoidControl pawn = FindObjectOfType<HumanoidControl>(); HumanoidControl pawn = FindObjectOfType<HumanoidControl>();
#endif
if (pawn == null) if (pawn == null)
return; return;
#if UNITY_6000_0_OR_NEWER
HumanoidSpawnPoint[] spawnPoints = FindObjectsByType<HumanoidSpawnPoint>(FindObjectsSortMode.None);
#else
HumanoidSpawnPoint[] spawnPoints = FindObjectsOfType<HumanoidSpawnPoint>(); HumanoidSpawnPoint[] spawnPoints = FindObjectsOfType<HumanoidSpawnPoint>();
#endif
foreach (HumanoidSpawnPoint spawnPoint in spawnPoints) { foreach (HumanoidSpawnPoint spawnPoint in spawnPoints) {
if (spawnPoint.isFree) if (spawnPoint.isFree)
pawn.transform.position = spawnPoint.transform.position; pawn.transform.position = spawnPoint.transform.position;

View File

@ -87,7 +87,7 @@ namespace Passer {
UnityEditor.SceneManagement.EditorSceneManager.LoadSceneInPlayMode(startScene, new LoadSceneParameters(LoadSceneMode.Additive)); UnityEditor.SceneManagement.EditorSceneManager.LoadSceneInPlayMode(startScene, new LoadSceneParameters(LoadSceneMode.Additive));
currentSite = new HistoryEntry() { currentSite = new HistoryEntry() {
siteName = "directload", siteName = "directload",
siteLocation = "serrarens.nl/sites/start", siteLocation = "passervr.com/sites/start",
scenePath = "", scenePath = "",
assetBundle = currentAssetBundle, assetBundle = currentAssetBundle,
}; };
@ -248,7 +248,7 @@ namespace Passer {
UnityEngine.UI.Text text = dialogObj.AddComponent<UnityEngine.UI.Text>(); UnityEngine.UI.Text text = dialogObj.AddComponent<UnityEngine.UI.Text>();
text.text = dialogText; text.text = dialogText;
text.font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf"); text.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
text.resizeTextForBestFit = true; text.resizeTextForBestFit = true;
text.alignment = TextAnchor.MiddleCenter; text.alignment = TextAnchor.MiddleCenter;

View File

@ -16,11 +16,7 @@ namespace Passer {
UnityEngine.SceneManagement.SceneManager.sceneLoaded += OnSceneLoad; UnityEngine.SceneManagement.SceneManager.sceneLoaded += OnSceneLoad;
#if UNITY_6000_0_OR_NEWER
HumanoidControl pawn = FindAnyObjectByType<HumanoidControl>();
#else
HumanoidControl pawn = FindObjectOfType<HumanoidControl>(); HumanoidControl pawn = FindObjectOfType<HumanoidControl>();
#endif
if (pawn == null) { if (pawn == null) {
UnityEngine.SceneManagement.SceneManager.LoadScene(sceneName); UnityEngine.SceneManagement.SceneManager.LoadScene(sceneName);
} }
@ -30,11 +26,7 @@ namespace Passer {
private void OnSceneLoad(UnityEngine.SceneManagement.Scene _, LoadSceneMode _1) { private void OnSceneLoad(UnityEngine.SceneManagement.Scene _, LoadSceneMode _1) {
#if UNITY_EDITOR #if UNITY_EDITOR
#if UNITY_6000_0_OR_NEWER
SiteNavigator siteNavigator = FindAnyObjectByType<SiteNavigator>();
#else
SiteNavigator siteNavigator = FindObjectOfType<SiteNavigator>(); SiteNavigator siteNavigator = FindObjectOfType<SiteNavigator>();
#endif
if (siteNavigator != null) { if (siteNavigator != null) {
siteNavigator.startScene = thisSceneName; siteNavigator.startScene = thisSceneName;
} }

View File

@ -1,9 +1,9 @@
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
namespace Passer { using Passer;
public class ControllerDebugger : MonoBehaviour { public class ControllerDebugger : MonoBehaviour {
[System.Serializable] [System.Serializable]
public struct ControllerSideDebugger { public struct ControllerSideDebugger {
@ -30,14 +30,14 @@ namespace Passer {
private Controller controller; private Controller controller;
private void Start() { private void Start () {
controller = Controllers.GetController(0); controller = Controllers.GetController(0);
left.buttons = new bool[4]; left.buttons = new bool[4];
right.buttons = new bool[4]; right.buttons = new bool[4];
} }
private void Update() { private void Update () {
UpdateSide(ref left, controller.left); UpdateSide(ref left, controller.left);
UpdateSide(ref right, controller.right); UpdateSide(ref right, controller.right);
} }
@ -63,6 +63,4 @@ namespace Passer {
sideDebugger.option = controllerSide.option; sideDebugger.option = controllerSide.option;
} }
}
} }

View File

@ -62,11 +62,9 @@ namespace Passer {
public float leftStickVertical { get { return controller.left.stickVertical; } } public float leftStickVertical { get { return controller.left.stickVertical; } }
public float leftStickHorizontal { get { return controller.left.stickHorizontal; } } 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 leftTouchpadVertical { get { return controller.left.touchpadVertical; } }
public float leftTouchpadHorizontal { get { return controller.left.touchpadHorizontal; } } 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 float leftTrigger1 { get { return controller.left.trigger1; } }
public bool leftTrigger1Touched { get { return controller.left.trigger1 > 0; } } public bool leftTrigger1Touched { get { return controller.left.trigger1 > 0; } }
@ -83,11 +81,9 @@ namespace Passer {
public float rightStickVertical { get { return controller.right.stickVertical; } } public float rightStickVertical { get { return controller.right.stickVertical; } }
public float rightStickHorizontal { get { return controller.right.stickHorizontal; } } 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 rightTouchpadVertical { get { return controller.right.touchpadVertical; } }
public float rightTouchpadHorizontal { get { return controller.right.touchpadHorizontal; } } 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 float rightTrigger1 { get { return controller.right.trigger1; } }
public bool rightTrigger1Touched { get { return controller.right.trigger1 > 0; } } public bool rightTrigger1Touched { get { return controller.right.trigger1 > 0; } }

View File

@ -229,11 +229,7 @@ namespace Passer {
damper = -velocityTowardsTarget * damping; damper = -velocityTowardsTarget * damping;
//Compensate for absolute rigidbody speed (specifically when on a moving platform) //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; Vector3 residualVelocity = thisRigidbody.velocity - velocityTowardsTarget;
#endif
damper += residualVelocity * 10; damper += residualVelocity * 10;
} }
lastDistanceToTarget = distanceToTarget; lastDistanceToTarget = distanceToTarget;
@ -324,34 +320,7 @@ namespace Passer {
Vector3 tmp = Vector3.Cross(a, b).normalized; Vector3 tmp = Vector3.Cross(a, b).normalized;
return tmp; 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 #region Utilities
@ -413,14 +382,6 @@ namespace Passer {
UnsetCollidersToTrigger(colliders); UnsetCollidersToTrigger(colliders);
} }
public static void SetNonKinematic(Rigidbody rigidbody, List<Collider> colliders) {
if (rigidbody == null)
return;
rigidbody.isKinematic = false;
UnsetCollidersToTrigger(colliders);
}
/// <summary> /// <summary>
/// Switches this Rigidbody to Hybrid Kinematic Mode /// Switches this Rigidbody to Hybrid Kinematic Mode
/// </summary> /// </summary>
@ -465,16 +426,6 @@ namespace Passer {
return changedColliders; 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 #endregion
#region Colliders #region Colliders
@ -585,11 +536,9 @@ namespace Passer {
if (colliders == null) if (colliders == null)
return; return;
foreach (Collider c in colliders) { foreach (Collider c in colliders)
if (c != null)
c.isTrigger = false; c.isTrigger = false;
} }
}
/// <summary> /// <summary>
/// Switches the Rigidbody to Non-Kinematic mode. /// Switches the Rigidbody to Non-Kinematic mode.
@ -603,11 +552,9 @@ namespace Passer {
if (colliders == null) if (colliders == null)
return; return;
foreach (Collider c in colliders) { foreach (Collider c in colliders)
if (c != null)
c.isTrigger = false; c.isTrigger = false;
} }
}
#endregion #endregion

View File

@ -30,13 +30,8 @@ namespace Passer {
public void CopyFromRigidbody(Rigidbody rb) { public void CopyFromRigidbody(Rigidbody rb) {
mass = rb.mass; mass = rb.mass;
#if UNITY_6000_0_OR_NEWER
drag = rb.linearDamping;
angularDrag = rb.angularDamping;
#else
drag = rb.drag; drag = rb.drag;
angularDrag = rb.angularDrag; angularDrag = rb.angularDrag;
#endif
useGravity = rb.useGravity; useGravity = rb.useGravity;
isKinematic = rb.isKinematic; isKinematic = rb.isKinematic;
interpolation = rb.interpolation; interpolation = rb.interpolation;
@ -49,13 +44,8 @@ namespace Passer {
public void CopyToRigidbody(Rigidbody rb) { public void CopyToRigidbody(Rigidbody rb) {
rb.mass = mass; rb.mass = mass;
#if UNITY_6000_0_OR_NEWER
rb.linearDamping = drag;
rb.angularDamping = angularDrag;
#else
rb.drag = drag; rb.drag = drag;
rb.angularDrag = angularDrag; rb.angularDrag = angularDrag;
#endif
rb.useGravity = useGravity; rb.useGravity = useGravity;
rb.isKinematic = isKinematic; rb.isKinematic = isKinematic;
rb.interpolation = interpolation; rb.interpolation = interpolation;

View File

@ -78,38 +78,6 @@ namespace Passer {
return newRotation1; 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 { public static class Vectors {
@ -142,4 +110,93 @@ 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;
// }
//}
} }

View File

@ -46,17 +46,13 @@ namespace Passer.Humanoid {
} }
} }
protected void Awake() { private void Awake() {
#if UNITY_6000_0_OR_NEWER
HumanoidControl humanoid = Object.FindAnyObjectByType<HumanoidControl>();
#else
HumanoidControl humanoid = FindObjectOfType<HumanoidControl>(); HumanoidControl humanoid = FindObjectOfType<HumanoidControl>();
#endif
if (humanoid == null) if (humanoid == null)
return; return;
Vector3 humanoidXZ = new(humanoid.transform.position.x, 0, humanoid.transform.position.z); Vector3 humanoidXZ = new Vector3(humanoid.transform.position.x, 0, humanoid.transform.position.z);
Vector3 thisXZ = new(this.transform.position.x, 0, this.transform.position.z); Vector3 thisXZ = new Vector3(this.transform.position.x, 0, this.transform.position.z);
float distance = Vector3.Distance(humanoidXZ, thisXZ); float distance = Vector3.Distance(humanoidXZ, thisXZ);
if (distance < radius || isFree) if (distance < radius || isFree)
humanoid.transform.MoveTo(this.transform.position); humanoid.transform.MoveTo(this.transform.position);

View File

@ -121,10 +121,8 @@ namespace Passer {
focusing = true; focusing = true;
return; return;
}
else
ProcessFocus();
}
if (!clicking) { // first activation if (!clicking) { // first activation
touchedObject = data.pointerCurrentRaycast.gameObject; touchedObject = data.pointerCurrentRaycast.gameObject;
if (touchedObject == null) // object is a 3D object, as we do not use Physicsraycaster, use the focusObject if (touchedObject == null) // object is a 3D object, as we do not use Physicsraycaster, use the focusObject
@ -256,11 +254,7 @@ namespace Passer {
if (pointers == null) if (pointers == null)
pointers = new InteractionPointer[maxInteractions]; // 0 = left index, 1 = right index, 2 = head, 3 = controller 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>(); EventSystem eventSystem = GameObject.FindObjectOfType<EventSystem>();
#endif
if (eventSystem == null) if (eventSystem == null)
eventSystem = humanoid.gameObject.AddComponent<EventSystem>(); eventSystem = humanoid.gameObject.AddComponent<EventSystem>();
@ -350,7 +344,7 @@ namespace Passer {
pointer.ProcessTouch(); pointer.ProcessTouch();
} }
#endregion #endregion
public Vector3 GetFocusPoint(int inputDeviceID) { public Vector3 GetFocusPoint(int inputDeviceID) {
return pointers[inputDeviceID].focusPosition; return pointers[inputDeviceID].focusPosition;
@ -534,15 +528,18 @@ namespace Passer {
if (Camera.main == null || pointer.type != PointerType.Touch) if (Camera.main == null || pointer.type != PointerType.Touch)
return; return;
//if (eventSystem == null)
// eventSystem = Object.FindObjectOfType<EventSystem>();
//if (eventSystem == null)
// return;
pointer.data.position = Camera.main.WorldToScreenPoint(pointer.pointerTransform.position); 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>(); System.Collections.Generic.List<RaycastResult> m_RaycastResultCache = new System.Collections.Generic.List<RaycastResult>();
eventSystem.RaycastAll(pointer.data, m_RaycastResultCache); eventSystem.RaycastAll(pointer.data, m_RaycastResultCache);
RaycastResult raycastResult = FindFirstRaycast(m_RaycastResultCache, distanceToPointer); RaycastResult raycastResult = FindFirstRaycast(m_RaycastResultCache);
m_RaycastResultCache.Clear(); m_RaycastResultCache.Clear();
if (raycastResult.gameObject != null) { if (raycastResult.gameObject != null) {
if (pointer.type == PointerType.Touch) { if (pointer.type == PointerType.Touch) {
float distance = DistanceTipToTransform(pointer.pointerTransform, raycastResult.gameObject.transform); float distance = DistanceTipToTransform(pointer.pointerTransform, raycastResult.gameObject.transform);
@ -562,15 +559,11 @@ namespace Passer {
} }
} }
private RaycastResult FindFirstRaycast(System.Collections.Generic.List<RaycastResult> raycastResults, float pointerDistance) { private new RaycastResult FindFirstRaycast(System.Collections.Generic.List<RaycastResult> raycastResults) {
foreach (RaycastResult result in raycastResults) { foreach (RaycastResult result in raycastResults) {
float resultDistance = Vector3.Distance(Camera.main.transform.position, result.worldPosition); if (result.isValid)
if (result.isValid &&
result.worldPosition != Vector3.zero &&
Mathf.Abs(resultDistance - pointerDistance) < 0.02F) {
return result; return result;
} }
}
return new RaycastResult(); return new RaycastResult();
} }
@ -586,6 +579,7 @@ namespace Passer {
} }
private float DistanceTipToTransform(Transform fingerTip, Transform transform) { private float DistanceTipToTransform(Transform fingerTip, Transform transform) {
//Debug.DrawLine(fingerTip.position, transform.position);
return (-transform.InverseTransformPoint(fingerTip.position).z * transform.lossyScale.z) - 0.01F; return (-transform.InverseTransformPoint(fingerTip.position).z * transform.lossyScale.z) - 0.01F;
} }
} }

View File

@ -224,11 +224,7 @@ namespace Passer {
protected virtual void Awake() { protected virtual void Awake() {
Transform rootTransform = this.transform.root; Transform rootTransform = this.transform.root;
#if UNITY_6000_0_OR_NEWER
interactionModule = FindAnyObjectByType<InteractionModule>();
#else
interactionModule = FindObjectOfType<InteractionModule>(); interactionModule = FindObjectOfType<InteractionModule>();
#endif
if (interactionModule == null) if (interactionModule == null)
interactionModule = CreateInteractionModule(); interactionModule = CreateInteractionModule();
EventSystem eventSystem = interactionModule.GetComponent<EventSystem>(); EventSystem eventSystem = interactionModule.GetComponent<EventSystem>();
@ -589,11 +585,7 @@ namespace Passer {
if (rayType != RayType.Gravity) if (rayType != RayType.Gravity)
return; return;
#if UNITY_6000_0_OR_NEWER
rigidbody.linearVelocity = transform.forward * speed;
#else
rigidbody.velocity = transform.forward * speed; rigidbody.velocity = transform.forward * speed;
#endif
} }
public void LaunchPrefab(GameObject prefab) { public void LaunchPrefab(GameObject prefab) {
@ -646,7 +638,7 @@ namespace Passer {
}; };
protected GameObject previousObjectInFocus; protected GameObject previousObjectInFocus;
protected virtual void UpdateFocus() { protected void UpdateFocus() {
focusEvent.value = objectInFocus; focusEvent.value = objectInFocus;
if (objectInFocus != previousObjectInFocus) { if (objectInFocus != previousObjectInFocus) {

View File

@ -658,7 +658,7 @@ namespace Passer {
} }
Handle handle = attachedHandle; Handle handle = attachedHandle; // attachedTransform.GetComponentInChildren<Handle>();
if (handle != null) { if (handle != null) {
handle.socket = null; handle.socket = null;
} }
@ -672,7 +672,7 @@ namespace Passer {
} }
// Released objects should be gone within 1 second or they will be reattached // Released objects should be gone within 1 second or they will be reattached
protected IEnumerator ClearReleasingTransform() { private IEnumerator ClearReleasingTransform() {
yield return new WaitForSeconds(1); yield return new WaitForSeconds(1);
this.releasingTransform = null; this.releasingTransform = null;
} }
@ -694,11 +694,7 @@ namespace Passer {
Humanoid.HumanoidNetworking.ReenableNetworkSync(objRigidbody.gameObject); Humanoid.HumanoidNetworking.ReenableNetworkSync(objRigidbody.gameObject);
if (thisRigidbody != null) { if (thisRigidbody != null) {
#if UNITY_6000_0_OR_NEWER
objRigidbody.linearVelocity = thisRigidbody.linearVelocity;
#else
objRigidbody.velocity = thisRigidbody.velocity; objRigidbody.velocity = thisRigidbody.velocity;
#endif
objRigidbody.angularVelocity = thisRigidbody.angularVelocity; objRigidbody.angularVelocity = thisRigidbody.angularVelocity;
} }
@ -765,7 +761,7 @@ namespace Passer {
} }
} }
#endregion Rigidbody #endregion Rigidbody
#region Static Object #region Static Object
@ -811,7 +807,7 @@ namespace Passer {
#endregion Static Object #endregion Static Object
#endregion Release #endregion Release
#region Start #region Start

View File

@ -54,11 +54,7 @@ namespace Passer {
if (spawnPoints != null && spawnPoints.Length > 0) if (spawnPoints != null && spawnPoints.Length > 0)
return; return;
#if UNITY_6000_0_OR_NEWER
spawnPoints = FindObjectsByType<SpawnPoint>(FindObjectsSortMode.None);
#else
spawnPoints = FindObjectsOfType<SpawnPoint>(); spawnPoints = FindObjectsOfType<SpawnPoint>();
#endif
if (spawnPoints.Length == 0) { if (spawnPoints.Length == 0) {
SpawnPoint thisSpawnPoint = this.gameObject.AddComponent<SpawnPoint>(); SpawnPoint thisSpawnPoint = this.gameObject.AddComponent<SpawnPoint>();
spawnPoints = new SpawnPoint[] { thisSpawnPoint }; spawnPoints = new SpawnPoint[] { thisSpawnPoint };

View File

@ -1,17 +1,18 @@
using UnityEngine; using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Passer { public class ShowVisitorName : MonoBehaviour
{
public class ShowVisitorName : MonoBehaviour {
// Start is called before the first frame update // Start is called before the first frame update
void Start() { void Start()
{
} }
// Update is called once per frame // Update is called once per frame
void Update() { void Update()
{
} }
}
} }

View File

@ -1,12 +1,8 @@
using UnityEngine; using UnityEngine;
namespace Passer { public class ToggleActive : MonoBehaviour {
public class ToggleActive : MonoBehaviour {
// Temporary helper script to implement toggling the gameobject active state // Temporary helper script to implement toggling the gameobject active state
public void Toggle() { public void Toggle() {
this.gameObject.SetActive(!this.gameObject.activeSelf); this.gameObject.SetActive(!this.gameObject.activeSelf);
} }
}
} }

View File

@ -1,4 +1,6 @@
using UnityEngine; using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
namespace Passer { namespace Passer {
@ -16,7 +18,7 @@ namespace Passer {
this.site = site; this.site = site;
} }
protected void OnEnable() { private void OnEnable() {
if (site == null) if (site == null)
return; return;
@ -26,11 +28,7 @@ namespace Passer {
} }
private void GoToSite() { private void GoToSite() {
#if UNITY_6000_0_OR_NEWER
SiteNavigator siteNavigator = FindAnyObjectByType<SiteNavigator>();
#else
SiteNavigator siteNavigator = FindObjectOfType<SiteNavigator>(); SiteNavigator siteNavigator = FindObjectOfType<SiteNavigator>();
#endif
if (siteNavigator == null) { if (siteNavigator == null) {
Debug.LogError("Could not find a site navigator"); Debug.LogError("Could not find a site navigator");
return; return;

View File

@ -150,11 +150,7 @@ namespace Passer {
} }
protected void ShowSite(VisitorSites.Site site, int position) { protected void ShowSite(VisitorSites.Site site, int position) {
#if UNITY_6000_0_OR_NEWER
SiteNavigator siteNavigator = FindAnyObjectByType<SiteNavigator>();
#else
SiteNavigator siteNavigator = FindObjectOfType<SiteNavigator>(); SiteNavigator siteNavigator = FindObjectOfType<SiteNavigator>();
#endif
if (siteNavigator == null) if (siteNavigator == null)
Debug.LogError("Could not find a site navigator"); Debug.LogError("Could not find a site navigator");
@ -214,7 +210,7 @@ namespace Passer {
} }
#endregion #endregion
public void AddSite(string siteName, string siteLocation) { public void AddSite(string siteName, string siteLocation) {
//Debug.Log("Add site " + siteName); //Debug.Log("Add site " + siteName);
@ -237,11 +233,7 @@ namespace Passer {
} }
private void GoToSite(VisitorSites.Site site) { private void GoToSite(VisitorSites.Site site) {
#if UNITY_6000_0_OR_NEWER
SiteNavigator siteNavigator = FindAnyObjectByType<SiteNavigator>();
#else
SiteNavigator siteNavigator = FindObjectOfType<SiteNavigator>(); SiteNavigator siteNavigator = FindObjectOfType<SiteNavigator>();
#endif
if (siteNavigator == null) { if (siteNavigator == null) {
Debug.LogError("Could not find a site navigator"); Debug.LogError("Could not find a site navigator");
return; return;

View File

@ -406,11 +406,7 @@ namespace Passer {
if (avatarIndex < 0 || avatarIndex > avatars.Count) if (avatarIndex < 0 || avatarIndex > avatars.Count)
return; return;
#if UNITY_6000_0_OR_NEWER
HumanoidControl humanoid = FindAnyObjectByType<HumanoidControl>();
#else
HumanoidControl humanoid = FindObjectOfType<HumanoidControl>(); HumanoidControl humanoid = FindObjectOfType<HumanoidControl>();
#endif
if (humanoid == null) if (humanoid == null)
return; return;
@ -424,11 +420,7 @@ namespace Passer {
} }
private static IEnumerator RetrieveAvatarAsync(Possession possession) { private static IEnumerator RetrieveAvatarAsync(Possession possession) {
#if UNITY_6000_0_OR_NEWER
HumanoidControl humanoid = FindAnyObjectByType<HumanoidControl>();
#else
HumanoidControl humanoid = FindObjectOfType<HumanoidControl>(); HumanoidControl humanoid = FindObjectOfType<HumanoidControl>();
#endif
if (humanoid == null) if (humanoid == null)
yield break; yield break;

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More