diff --git a/Assets/Game/Scripts/CardboardScript.cs b/Assets/Game/Scripts/CardboardScript.cs index 149b39e..8ff9b05 100644 --- a/Assets/Game/Scripts/CardboardScript.cs +++ b/Assets/Game/Scripts/CardboardScript.cs @@ -3,32 +3,52 @@ public class CardboardScript : MonoBehaviour { - public float WatchDownAngle; - public float angle; + public float SmoothFactor; + public float ForwardRotationThresholdMin; + public float ForwardRotationThresholdMax; private PlayerScript player; - private bool lookDown; private float lastRotation; - private bool locked; void Start () { player = MainScript.Get ().Player; lookDown = false; - locked = false; } /* * Rotation system */ void Update () { - var headRotation = Cardboard.SDK.HeadPose.Orientation.eulerAngles; // Head rotation - - if (locked) { - transform.eulerAngles = new Vector3 (headRotation.x, headRotation.y, headRotation.z); - return; + var headRotation = Cardboard.SDK.HeadPose.Orientation.eulerAngles; // Head rotation + var neckVector = Cardboard.SDK.HeadPose.Orientation * Vector3.up; // Neck vector + + var direction = new Vector3 (neckVector.x, 0, neckVector.z); + Debug.Log("direction" + direction + "; Headrotation: " + headRotation); + + var lookHorizontally = headRotation.x < ForwardRotationThresholdMin || headRotation.x > ForwardRotationThresholdMax; + if (!lookHorizontally) { + lookDown = true; + var playerTarget = Quaternion.LookRotation (direction); + player.transform.rotation = Quaternion.Slerp(player.transform.rotation, playerTarget, Time.deltaTime * SmoothFactor); + } else { + if(lookDown){ //Fix the jump glitch + lookDown = false; + transform.eulerAngles = new Vector3 (headRotation.x, lastRotation, headRotation.z); + } + player.transform.rotation = Quaternion.Slerp(player.transform.rotation, Quaternion.Euler (0, headRotation.y, 0), Time.deltaTime * SmoothFactor); } + var target = Quaternion.Euler (headRotation.x, headRotation.y, headRotation.z); + transform.rotation = Quaternion.Slerp(transform.rotation, target, Time.deltaTime * SmoothFactor); + lastRotation = transform.rotation.y; + //transform.eulerAngles = new Vector3 (headRotation.x, headRotation.y, headRotation.z); + + return; + /* + * OLD SYSTEM + * + var headRotation = Cardboard.SDK.HeadPose.Orientation.eulerAngles; // Head rotation var forwardRotationThresholdMin = 10; // Player look in direction of the ground/ball var forwardRotationThresholdMax = 90; @@ -51,6 +71,6 @@ void Update () { player.transform.rotation = Quaternion.LookRotation (direction); // TODO: add a little threshold? transform.eulerAngles = new Vector3 (headRotation.x, headRotation.y, headRotation.z); lastRotation = headRotation.y; - } + }*/ } } diff --git a/Assets/GolfVR.unity b/Assets/GolfVR.unity index 1afe91d..4f2b3df 100644 --- a/Assets/GolfVR.unity +++ b/Assets/GolfVR.unity @@ -37,6 +37,9 @@ RenderSettings: m_ReflectionIntensity: 0 m_CustomReflection: {fileID: 8900000, guid: e3753214bd9dfbe499f5bc60bc3c425a, type: 3} m_Sun: {fileID: 1439804818} +--- !u!127 &3 +LevelGameManager: + m_ObjectHideFlags: 0 --- !u!157 &4 LightmapSettings: m_ObjectHideFlags: 0 @@ -66,7 +69,6 @@ LightmapSettings: m_TextureCompression: 1 m_FinalGather: 1 m_FinalGatherRayCount: 256 - m_ReflectionCompression: 2 m_LightmapSnapshot: {fileID: 112000001, guid: 35ea626331019b048b00eea6d3e93f1c, type: 2} m_RuntimeCPUUsage: 25 @@ -204,12 +206,6 @@ MonoBehaviour: m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 0, g: 0, b: 0, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null m_FontData: m_Font: {fileID: 12800000, guid: 6f53d5f03bde5cf4fa9639ea0d47c994, type: 3} m_FontSize: 0 @@ -1679,8 +1675,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 2a1826a83bf1ab646a572a66b8c782ee, type: 3} m_Name: m_EditorClassIdentifier: - WatchDownAngle: 40 - angle: 0 + SmoothFactor: 20 + ForwardRotationThresholdMin: 10 + ForwardRotationThresholdMax: 90 --- !u!1 &804225126 GameObject: m_ObjectHideFlags: 0 @@ -1815,12 +1812,6 @@ MonoBehaviour: m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 1, g: .764705896, b: 0, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null m_Sprite: {fileID: 21300000, guid: bae9cd1faed980247a4a64276065f6bf, type: 3} m_Type: 0 m_PreserveAspect: 0 @@ -1882,12 +1873,6 @@ MonoBehaviour: m_EditorClassIdentifier: m_Material: {fileID: 2100000, guid: 3e490a39bd5f9da4fb11a176e2499636, type: 2} m_Color: {r: 1, g: .765517235, b: 0, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null m_Sprite: {fileID: 21300000, guid: a40e9e3d6add37042b3dffe2fa57bd58, type: 3} m_Type: 3 m_PreserveAspect: 0 @@ -1943,19 +1928,19 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 496262, guid: 7737647c22c1fc64a88d5cd030c352ce, type: 2} propertyPath: m_LocalRotation.x - value: .532675207 + value: .532675147 objectReference: {fileID: 0} - target: {fileID: 496262, guid: 7737647c22c1fc64a88d5cd030c352ce, type: 2} propertyPath: m_LocalRotation.y - value: .0703404546 + value: .0703404471 objectReference: {fileID: 0} - target: {fileID: 496262, guid: 7737647c22c1fc64a88d5cd030c352ce, type: 2} propertyPath: m_LocalRotation.z - value: .836132765 + value: .836132646 objectReference: {fileID: 0} - target: {fileID: 496262, guid: 7737647c22c1fc64a88d5cd030c352ce, type: 2} propertyPath: m_LocalRotation.w - value: -.110415146 + value: -.110415131 objectReference: {fileID: 0} - target: {fileID: 469942, guid: 7737647c22c1fc64a88d5cd030c352ce, type: 2} propertyPath: m_LocalPosition.y @@ -2395,12 +2380,6 @@ MonoBehaviour: m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 1, g: 0, b: 0, a: 1} - m_RaycastTarget: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, - Version=1.0.0.0, Culture=neutral, PublicKeyToken=null m_FontData: m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} m_FontSize: 0 @@ -2408,7 +2387,7 @@ MonoBehaviour: m_BestFit: 0 m_MinSize: 10 m_MaxSize: 40 - m_Alignment: 0 + m_Alignment: 4 m_RichText: 1 m_HorizontalOverflow: 1 m_VerticalOverflow: 1 @@ -3505,7 +3484,7 @@ Prefab: objectReference: {fileID: 0} - target: {fileID: 11400012, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} propertyPath: deviceType - value: 1 + value: 2 objectReference: {fileID: 0} - target: {fileID: 100002, guid: b8b03d395f5734e98af91ccf44f9bf47, type: 2} propertyPath: m_Layer diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index c41c4f6..680a8b7 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -60,23 +60,11 @@ PlayerSettings: xboxSpeechDB: 0 xboxEnableHeadOrientation: 0 xboxEnableGuest: 0 - n3dsDisableStereoscopicView: 0 - n3dsEnableSharedListOpt: 1 - n3dsEnableVSync: 0 xboxOneResolution: 0 ps3SplashScreen: {fileID: 0} videoMemoryForVertexBuffers: 0 psp2PowerMode: 0 psp2AcquireBGM: 1 - wiiUTVResolution: 0 - wiiUGamePadMSAA: 1 - wiiUSupportsNunchuk: 0 - wiiUSupportsClassicController: 0 - wiiUSupportsBalanceBoard: 0 - wiiUSupportsMotionPlus: 0 - wiiUSupportsProController: 0 - wiiUAllowScreenCapture: 1 - wiiUControllerCount: 0 m_SupportedAspectRatios: 4:3: 1 5:4: 1 @@ -89,26 +77,20 @@ PlayerSettings: metroEnableIndependentInputSource: 0 metroEnableLowLatencyPresentationAPI: 0 xboxOneDisableKinectGpuReservation: 0 - virtualRealitySupported: 0 productGUID: cf97b928b03ef4744a6314aeba387abe AndroidBundleVersionCode: 1 AndroidMinSdkVersion: 9 AndroidPreferredInstallLocation: 1 aotOptions: apiCompatibilityLevel: 2 - stripEngineCode: 1 iPhoneStrippingLevel: 0 iPhoneScriptCallOptimization: 0 - iPhoneBuildNumber: 0 ForceInternetPermission: 0 ForceSDCardPermission: 0 CreateWallpaper: 0 APKExpansionFiles: 0 preloadShaders: 0 StripUnusedMeshComponents: 0 - VertexChannelCompressionMask: - serializedVersion: 2 - m_Bits: 238 iPhoneSdkVersion: 988 iPhoneTargetOSVersion: 22 uIPrerenderedIcon: 0 @@ -161,23 +143,6 @@ PlayerSettings: m_BuildTargetGraphicsAPIs: [] webPlayerTemplate: APPLICATION:Default m_TemplateCustomTags: {} - wiiUTitleID: 0005000011000000 - wiiUGroupID: 00010000 - wiiUCommonSaveSize: 4096 - wiiUAccountSaveSize: 2048 - wiiUOlvAccessKey: 0 - wiiUTinCode: 0 - wiiUJoinGameId: 0 - wiiUJoinGameModeMask: 0000000000000000 - wiiUCommonBossSize: 0 - wiiUAccountBossSize: 0 - wiiUAddOnUniqueIDs: [] - wiiUMainThreadStackSize: 3072 - wiiULoaderThreadStackSize: 1024 - wiiUSystemHeapSize: 128 - wiiUTVStartupScreen: {fileID: 0} - wiiUGamePadStartupScreen: {fileID: 0} - wiiUProfilerLibPath: actionOnDotNetUnhandledException: 1 enableInternalProfiler: 0 logObjCUncaughtExceptions: 1 @@ -228,18 +193,15 @@ PlayerSettings: ps4BackgroundImagePath: ps4StartupImagePath: ps4SaveDataImagePath: - ps4SdkOverride: ps4BGMPath: ps4ShareFilePath: ps4NPtitleDatPath: ps4RemotePlayKeyAssignment: -1 - ps4RemotePlayKeyMappingDir: ps4EnterButtonAssignment: 1 ps4ApplicationParam1: 0 ps4ApplicationParam2: 0 ps4ApplicationParam3: 0 ps4ApplicationParam4: 0 - ps4DownloadDataSize: 0 ps4GarlicHeapSize: 2048 ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ ps4pnSessions: 1 @@ -247,11 +209,6 @@ PlayerSettings: ps4pnFriends: 1 ps4pnGameCustomData: 1 playerPrefsSupport: 0 - ps4ReprojectionSupport: 0 - ps4attribUserManagement: 0 - ps4attribMoveSupport: 0 - ps4attrib3DSupport: 0 - ps4attribShareSupport: 0 monoEnv: psp2Splashimage: {fileID: 0} psp2NPTrophyPackPath: @@ -300,6 +257,7 @@ PlayerSettings: psp2InfoBarOnStartup: 0 psp2InfoBarColor: 0 psmSplashimage: {fileID: 0} + virtualRealitySupported: 0 spritePackerPolicy: scriptingDefineSymbols: 1: CROSS_PLATFORM_INPUT @@ -400,17 +358,6 @@ PlayerSettings: tizenSigningProfileName: tizenGPSPermissions: 0 tizenMicrophonePermissions: 0 - n3dsUseExtSaveData: 0 - n3dsCompressStaticMem: 1 - n3dsExtSaveDataNumber: 0x12345 - n3dsStackSize: 131072 - n3dsTargetPlatform: 2 - n3dsRegion: 7 - n3dsMediaSize: 0 - n3dsLogoStyle: 3 - n3dsTitle: GameName - n3dsProductCode: - n3dsApplicationId: 0xFF3FF stvDeviceAddress: stvProductDescription: stvProductAuthor: @@ -474,6 +421,7 @@ PlayerSettings: additionalIl2CppArgs::additionalIl2CppArgs: firstStreamedSceneWithResources: 0 cloudProjectId: + projectId: projectName: organizationId: cloudEnabled: 0