Add platform manager
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										22
									
								
								Assets/Scripts/PlatformManager.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								Assets/Scripts/PlatformManager.cs
									
									
									
									
									
										Normal file
									
								
							@@ -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);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										11
									
								
								Assets/Scripts/PlatformManager.cs.meta
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								Assets/Scripts/PlatformManager.cs.meta
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
fileFormatVersion: 2
 | 
			
		||||
guid: fdc803964e5f2b042bece1765b69164f
 | 
			
		||||
MonoImporter:
 | 
			
		||||
  externalObjects: {}
 | 
			
		||||
  serializedVersion: 2
 | 
			
		||||
  defaultReferences: []
 | 
			
		||||
  executionOrder: 0
 | 
			
		||||
  icon: {instanceID: 0}
 | 
			
		||||
  userData: 
 | 
			
		||||
  assetBundleName: 
 | 
			
		||||
  assetBundleVariant: 
 | 
			
		||||
@@ -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<PlatformManager>();
 | 
			
		||||
            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;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user