diff --git a/Assets/Prefabs/Platform.prefab b/Assets/Prefabs/Platform.prefab index d357722..011a3d1 100644 --- a/Assets/Prefabs/Platform.prefab +++ b/Assets/Prefabs/Platform.prefab @@ -13,6 +13,7 @@ GameObject: - component: {fileID: 8768991388683709950} - component: {fileID: 8768991388683709945} - component: {fileID: 8768991388683709948} + - component: {fileID: 3861707493128515586} m_Layer: 0 m_Name: Platform m_TagString: platform @@ -27,7 +28,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 +115,16 @@ MonoBehaviour: renderer: {fileID: 8768991388683709950} emissionUp: 1 emmisionStepChange: 40 +--- !u!114 &3861707493128515586 +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: 0 diff --git a/Assets/Prefabs/Platform_Blue.prefab b/Assets/Prefabs/Platform_Blue.prefab index 6e08269..2c65de3 100644 --- a/Assets/Prefabs/Platform_Blue.prefab +++ b/Assets/Prefabs/Platform_Blue.prefab @@ -13,6 +13,7 @@ GameObject: - component: {fileID: 8768991388683709950} - component: {fileID: 8768991388683709945} - component: {fileID: 8768991388683709948} + - component: {fileID: 1430690303722568316} m_Layer: 0 m_Name: Platform_Blue m_TagString: platform @@ -27,7 +28,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 +115,16 @@ MonoBehaviour: renderer: {fileID: 8768991388683709950} emissionUp: 1 emmisionStepChange: 40 +--- !u!114 &1430690303722568316 +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: 0 diff --git a/Assets/Prefabs/Platform_Green.prefab b/Assets/Prefabs/Platform_Green.prefab index 480437f..62a2d4e 100644 --- a/Assets/Prefabs/Platform_Green.prefab +++ b/Assets/Prefabs/Platform_Green.prefab @@ -13,6 +13,7 @@ GameObject: - component: {fileID: 8768991388683709950} - component: {fileID: 8768991388683709945} - component: {fileID: 8768991388683709948} + - component: {fileID: 3339862426328537977} m_Layer: 0 m_Name: Platform_Green m_TagString: platform @@ -27,7 +28,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 +115,16 @@ MonoBehaviour: renderer: {fileID: 8768991388683709950} emissionUp: 1 emmisionStepChange: 20 +--- !u!114 &3339862426328537977 +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: 1 diff --git a/Assets/Scripts/PlatformManager.cs b/Assets/Scripts/PlatformManager.cs new file mode 100644 index 0000000..22923ad --- /dev/null +++ b/Assets/Scripts/PlatformManager.cs @@ -0,0 +1,22 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PlatformManager : MonoBehaviour +{ + public enum PlatformType {Pull, Push, Rotate}; + public PlatformType type = PlatformType.Pull; + + void Start() + { + + } + + void FixedUpdate() + { + if (type == PlatformType.Rotate) + { + transform.Rotate(transform.forward); + } + } +} diff --git a/Assets/Scripts/PlatformManager.cs.meta b/Assets/Scripts/PlatformManager.cs.meta new file mode 100644 index 0000000..b1c33bb --- /dev/null +++ b/Assets/Scripts/PlatformManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fdc803964e5f2b042bece1765b69164f +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 2a7e60d..41cd8e2 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -45,7 +45,7 @@ public class PlayerController : MonoBehaviour moveDirection = (transform.forward * curSpeedX * Time.deltaTime) + (transform.right * curSpeedY * Time.deltaTime); - if (Input.GetKeyDown(KeyCode.Space) && isGoundet) + if (Input.GetKeyUp(KeyCode.Space) && isGoundet) { Debug.Log("Jump"); rb.AddForce(transform.up * jumpSpeed * 500 * Time.deltaTime, ForceMode.Impulse); @@ -71,8 +71,15 @@ public class PlayerController : MonoBehaviour angle = Mathf.Atan2(Vector3.Magnitude(axis), Vector3.Dot(-transform.up, -other.transform.up)); transform.RotateAround(axis, angle); } - - Vector3 gDirection = new Quaternion(0.0f, 0.0f, other.gameObject.transform.rotation.z, 1.0f) * Vector3.down; + 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; + } 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; + } else { + gDirection = new Quaternion(0.0f, 0.0f, other.gameObject.transform.rotation.z, 1.0f) * Vector3.down; + } Physics.gravity = gDirection * 9.81f; }