From 544868c3866b997eedd0cf7e45a518399c9cd7a1 Mon Sep 17 00:00:00 2001 From: nexovec Date: Fri, 28 Jan 2022 23:18:07 +0100 Subject: [PATCH] broken player rotation --- Assets/Scenes/SampleScene.unity | 8 ++++---- Assets/Scripts/PlayerController.cs | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index a6cdcb8..6407fa8 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -363,7 +363,7 @@ GameObject: - component: {fileID: 708734973} m_Layer: 0 m_Name: Cube - m_TagString: Untagged + m_TagString: platform m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -460,7 +460,7 @@ GameObject: - component: {fileID: 875163559} m_Layer: 0 m_Name: Cube (4) - m_TagString: Untagged + m_TagString: platform m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -558,7 +558,7 @@ GameObject: - component: {fileID: 1429068750} m_Layer: 0 m_Name: Cube (1) - m_TagString: Untagged + m_TagString: platform m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -720,7 +720,7 @@ GameObject: - component: {fileID: 2031243810} m_Layer: 0 m_Name: Cube (3) - m_TagString: Untagged + m_TagString: platform m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index f8d7bcf..75e28f6 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -62,11 +62,13 @@ public class PlayerController : MonoBehaviour { if (collision.gameObject.tag == "platform") { - this.gameObject.transform.rotation = collision.gameObject.transform.rotation; + -- FIXME: + var thisTransform = this.gameObject.transform; + thisTransform.eulerAngles = new Vector3(thisTransform.eulerAngles.x, thisTransform.eulerAngles.y, collision.transform.eulerAngles.z); - Vector3 direction = collision.gameObject.transform.rotation * Vector3.down; + Vector3 gDirection = new Quaternion(0.0f, 0.0f, collision.gameObject.transform.rotation.z, 1.0f) * Vector3.down; - Physics.gravity = direction * 9.81f; + Physics.gravity = gDirection * 9.81f; Debug.Log(Physics.gravity); //Physics.gravity = -Physics.gravity; }