From 4bf7d9fc1a38d58bdf41ac8e2dcaac50cda5f1e6 Mon Sep 17 00:00:00 2001 From: haitem Date: Sun, 30 Jan 2022 10:58:20 +0100 Subject: [PATCH] Player move repair and add bgrotation script --- Assets/Prefabs/Player.prefab | 4 ++-- Assets/Scripts/BGRotation.cs | 19 +++++++++++++++++++ Assets/Scripts/BGRotation.cs.meta | 11 +++++++++++ Assets/Scripts/PlayerController.cs | 7 +++++-- 4 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 Assets/Scripts/BGRotation.cs create mode 100644 Assets/Scripts/BGRotation.cs.meta diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index ebc820d..7fe5b0c 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -1628,8 +1628,8 @@ MonoBehaviour: isFalling: 0 jumpSpeed: 3 inAir: 0 - lookSpeed: 7.5 - lookXLimit: 8.75 + lookSpeed: 5 + lookXLimit: 10 playerCamera: {fileID: 3244356567913423211} rotationX: 0 runningParticles: {fileID: 1608137079} diff --git a/Assets/Scripts/BGRotation.cs b/Assets/Scripts/BGRotation.cs new file mode 100644 index 0000000..8a1f1e8 --- /dev/null +++ b/Assets/Scripts/BGRotation.cs @@ -0,0 +1,19 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class BGRotation : MonoBehaviour +{ + void Update() + { + transform.Rotate(new Vector3(Random.Range(0,360), Random.Range(0, 360), Random.Range(0, 360))); + } + + private void OnTriggerEnter(Collider other) + { + if (other.tag == "platform") + { + Destroy(this.gameObject); + } + } +} diff --git a/Assets/Scripts/BGRotation.cs.meta b/Assets/Scripts/BGRotation.cs.meta new file mode 100644 index 0000000..5f3a159 --- /dev/null +++ b/Assets/Scripts/BGRotation.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 057be10618539f04aa0b770181500753 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index 2731f4a..6585f23 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -39,6 +39,7 @@ public class PlayerController : MonoBehaviour private Vector3 saveDirection; private Vector3 downDirection; private Vector3 platformForward; + private Vector3 platformRight; private Vector3 follow = Vector3.zero; @@ -49,6 +50,7 @@ public class PlayerController : MonoBehaviour { rb = GetComponent(); platformForward = Vector3.forward; + platformRight = Vector3.right; } public void disableCursor() @@ -87,7 +89,7 @@ public class PlayerController : MonoBehaviour float curSpeedX = canMove ? (currentSpeed + speedModifier) : 0; float curSpeedY = canMove ? (currentSpeed + currentSpeed + speedModifier) * Input.GetAxis("Horizontal") : 0; - moveDirection = (platformForward * curSpeedX * Time.deltaTime) + (transform.right * curSpeedY * Time.deltaTime); + moveDirection = (transform.forward * curSpeedX * Time.deltaTime) + (transform.right * curSpeedY * Time.deltaTime); if ((currentSpeed + speedModifier) >= maxSpeed && !runningParticles.isPlaying) { @@ -227,7 +229,7 @@ public class PlayerController : MonoBehaviour { return; } - this.downDirection = -other.GetContact(0).normal; + this.downDirection = -transform.up; saveDirection = -other.GetContact(0).normal; // TODO: Handle other PlatformTypes @@ -291,6 +293,7 @@ public class PlayerController : MonoBehaviour gDirection = -other.GetContact(0).normal; } platformForward = other.transform.forward; + platformRight = other.transform.right; this.downDirection = gDirection; Physics.gravity = gDirection * 9.81f; }