From 94950a79a1172a938c3ae5f3a475319a873339c7 Mon Sep 17 00:00:00 2001 From: haitem Date: Sat, 29 Jan 2022 03:15:33 +0100 Subject: [PATCH] Some edits --- Assets/Materials/Neon_green 1.mat | 10 ++++----- Assets/Prefabs/Platform.prefab | 14 +++++++++++++ Assets/Prefabs/Platform_Blue.prefab | 14 +++++++++++++ Assets/Prefabs/Platform_Green.prefab | 14 +++++++++++++ Assets/Prefabs/Platform_yellow.prefab | 30 ++++++++++++++++++++++++++- Assets/Prefabs/Player.prefab | 1 + Assets/Scripts/PlayerController.cs | 23 +++++++++++++------- 7 files changed, 92 insertions(+), 14 deletions(-) diff --git a/Assets/Materials/Neon_green 1.mat b/Assets/Materials/Neon_green 1.mat index 908b930..4a9a66f 100644 --- a/Assets/Materials/Neon_green 1.mat +++ b/Assets/Materials/Neon_green 1.mat @@ -9,8 +9,8 @@ Material: m_PrefabAsset: {fileID: 0} m_Name: Neon_green 1 m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} - m_ShaderKeywords: _EMISSION - m_LightmapFlags: 2 + m_ShaderKeywords: + m_LightmapFlags: 4 m_EnableInstancingVariants: 0 m_DoubleSidedGI: 0 m_CustomRenderQueue: -1 @@ -36,7 +36,7 @@ Material: m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} - _EmissionMap: - m_Texture: {fileID: 2800000, guid: 4d42022c70fc0a64a92c678cbc70449f, type: 3} + m_Texture: {fileID: 0} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} - _MainTex: @@ -74,6 +74,6 @@ Material: - _UVSec: 0 - _ZWrite: 1 m_Colors: - - _Color: {r: 0, g: 0, b: 0, a: 1} - - _EmissionColor: {r: 0.4392157, g: 5.1137257, b: 5.992157, a: 1} + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} m_BuildTextureStacks: [] diff --git a/Assets/Prefabs/Platform.prefab b/Assets/Prefabs/Platform.prefab index 011a3d1..8d6e0f1 100644 --- a/Assets/Prefabs/Platform.prefab +++ b/Assets/Prefabs/Platform.prefab @@ -14,6 +14,7 @@ GameObject: - component: {fileID: 8768991388683709945} - component: {fileID: 8768991388683709948} - component: {fileID: 3861707493128515586} + - component: {fileID: 5765921883283663682} m_Layer: 0 m_Name: Platform m_TagString: platform @@ -128,3 +129,16 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: type: 0 +--- !u!65 &5765921883283663682 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8768991388683709947} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 1, z: 0} diff --git a/Assets/Prefabs/Platform_Blue.prefab b/Assets/Prefabs/Platform_Blue.prefab index 2c65de3..a709f8b 100644 --- a/Assets/Prefabs/Platform_Blue.prefab +++ b/Assets/Prefabs/Platform_Blue.prefab @@ -14,6 +14,7 @@ GameObject: - component: {fileID: 8768991388683709945} - component: {fileID: 8768991388683709948} - component: {fileID: 1430690303722568316} + - component: {fileID: 4716169668968050713} m_Layer: 0 m_Name: Platform_Blue m_TagString: platform @@ -128,3 +129,16 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: type: 0 +--- !u!65 &4716169668968050713 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8768991388683709947} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 1, z: 0} diff --git a/Assets/Prefabs/Platform_Green.prefab b/Assets/Prefabs/Platform_Green.prefab index 62a2d4e..08e8e8b 100644 --- a/Assets/Prefabs/Platform_Green.prefab +++ b/Assets/Prefabs/Platform_Green.prefab @@ -14,6 +14,7 @@ GameObject: - component: {fileID: 8768991388683709945} - component: {fileID: 8768991388683709948} - component: {fileID: 3339862426328537977} + - component: {fileID: 1376546613772517290} m_Layer: 0 m_Name: Platform_Green m_TagString: platform @@ -128,3 +129,16 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: type: 1 +--- !u!65 &1376546613772517290 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8768991388683709947} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 1, z: 0} diff --git a/Assets/Prefabs/Platform_yellow.prefab b/Assets/Prefabs/Platform_yellow.prefab index eada372..a4e4d75 100644 --- a/Assets/Prefabs/Platform_yellow.prefab +++ b/Assets/Prefabs/Platform_yellow.prefab @@ -13,6 +13,8 @@ GameObject: - component: {fileID: 8768991388683709950} - component: {fileID: 8768991388683709945} - component: {fileID: 8768991388683709948} + - component: {fileID: 7821003709828495146} + - component: {fileID: 8066117290360009672} m_Layer: 0 m_Name: Platform_yellow m_TagString: platform @@ -27,7 +29,7 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 8768991388683709947} - m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: -92.17318, y: -60.5, z: -48.028496} m_LocalScale: {x: 6.7204876, y: 1.5078, z: 16.238924} m_ConstrainProportionsScale: 0 @@ -114,3 +116,29 @@ MonoBehaviour: renderer: {fileID: 8768991388683709950} emissionUp: 1 emmisionStepChange: 20 +--- !u!114 &7821003709828495146 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8768991388683709947} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fdc803964e5f2b042bece1765b69164f, type: 3} + m_Name: + m_EditorClassIdentifier: + type: 2 +--- !u!65 &8066117290360009672 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8768991388683709947} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 1, z: 0} diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index 66180c1..9a002b8 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -4998,6 +4998,7 @@ MonoBehaviour: playerCamera: {fileID: 3244356567913423211} runningParticles: {fileID: 1608137079} rotationX: 0 + mainObject: {fileID: 3244356567786994345} jump: {x: 0, y: 2, z: 0} jumpForce: 2 isRunning: 0 diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index a02bf9f..51d0f74 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -13,6 +13,7 @@ public class PlayerController : MonoBehaviour public ParticleSystem runningParticles; Vector3 moveDirection = Vector3.zero; public float rotationX = 0; + public Transform mainObject; // Start is called before the first frame update [HideInInspector] bool canMove = true; @@ -23,6 +24,8 @@ public class PlayerController : MonoBehaviour private bool isGoundet = false; public bool isRunning = false; + private Vector3 follow = Vector3.zero; + void Start() { rb = GetComponent(); @@ -64,35 +67,39 @@ public class PlayerController : MonoBehaviour rb.MovePosition(rb.position + moveDirection); } - void OnCollisionEnter(Collision other) + void OnCollisionStay(Collision other) { isGoundet = true; if (other.gameObject.tag == "platform") { - var thisTransform = this.gameObject.transform; - Vector3 axis; float angle; - axis = Vector3.Cross(-transform.up, -other.transform.up); + axis = Vector3.Cross(-transform.up, -other.GetContact(0).normal); if (axis != Vector3.zero) { - angle = Mathf.Atan2(Vector3.Magnitude(axis), Vector3.Dot(-transform.up, -other.transform.up)); + angle = Mathf.Atan2(Vector3.Magnitude(axis), Vector3.Dot(-transform.up, -other.GetContact(0).normal)); transform.RotateAround(axis, angle); } + Vector3 gDirection; PlatformManager platform = other.gameObject.GetComponent(); + if (platform != null && platform.type == PlatformManager.PlatformType.Pull) { - gDirection = new Quaternion(0.0f, 0.0f, other.gameObject.transform.rotation.z, 1.0f) * Vector3.down; + gDirection = -transform.up; } else if (platform != null && platform.type == PlatformManager.PlatformType.Push) { - gDirection = new Quaternion(0.0f, 0.0f, other.gameObject.transform.rotation.z, 1.0f) * Vector3.up; + gDirection = transform.up; + } + else if (platform != null && (platform.type == PlatformManager.PlatformType.RotateY || platform.type == PlatformManager.PlatformType.RotateZ)) + { + gDirection = -transform.up; } else { - gDirection = new Quaternion(0.0f, 0.0f, other.gameObject.transform.rotation.z, 1.0f) * Vector3.down; + gDirection = -transform.up; } Physics.gravity = gDirection * 9.81f;