Updated platform scripts

This commit is contained in:
OverflowNarhoym 2022-02-25 19:05:28 +01:00
parent b5a1f99cb8
commit 805aeb2d82
3 changed files with 87 additions and 15 deletions

View File

@ -123,6 +123,79 @@ NavMeshSettings:
debug: debug:
m_Flags: 0 m_Flags: 0
m_NavMeshData: {fileID: 0} m_NavMeshData: {fileID: 0}
--- !u!1001 &53543450
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_RootOrder
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_LocalPosition.x
value: 8.327312
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_LocalPosition.y
value: -2.1712146
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349115, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_BodyType
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349115, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_Constraints
value: 4
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349115, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_Interpolate
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349115, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_GravityScale
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349118, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_Name
value: Moving_Platform_Medium
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
--- !u!1 &387708699 --- !u!1 &387708699
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -209,7 +282,7 @@ Transform:
m_Children: m_Children:
- {fileID: 1287783379} - {fileID: 1287783379}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 8 m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!61 &387708702 --- !u!61 &387708702
BoxCollider2D: BoxCollider2D:
@ -254,10 +327,10 @@ Rigidbody2D:
m_AngularDrag: 0.05 m_AngularDrag: 0.05
m_GravityScale: 1 m_GravityScale: 1
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_Interpolate: 0 m_Interpolate: 1
m_SleepingMode: 1 m_SleepingMode: 1
m_CollisionDetection: 0 m_CollisionDetection: 1
m_Constraints: 0 m_Constraints: 4
--- !u!114 &387708704 --- !u!114 &387708704
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -2481,7 +2554,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6701593432788782526, guid: 85e13cc38c9c13145bdb0c612c6e2cbe, type: 3} - target: {fileID: 6701593432788782526, guid: 85e13cc38c9c13145bdb0c612c6e2cbe, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 5 value: 6
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6701593432788782526, guid: 85e13cc38c9c13145bdb0c612c6e2cbe, type: 3} - target: {fileID: 6701593432788782526, guid: 85e13cc38c9c13145bdb0c612c6e2cbe, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
@ -2714,7 +2787,7 @@ Transform:
m_Children: m_Children:
- {fileID: 434782289} - {fileID: 434782289}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 3 m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1001 &1692941248 --- !u!1001 &1692941248
PrefabInstance: PrefabInstance:
@ -2729,7 +2802,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6701593432788782526, guid: 85e13cc38c9c13145bdb0c612c6e2cbe, type: 3} - target: {fileID: 6701593432788782526, guid: 85e13cc38c9c13145bdb0c612c6e2cbe, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 7 value: 8
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 6701593432788782526, guid: 85e13cc38c9c13145bdb0c612c6e2cbe, type: 3} - target: {fileID: 6701593432788782526, guid: 85e13cc38c9c13145bdb0c612c6e2cbe, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
@ -2843,7 +2916,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 5846939066456683150, guid: 31e12405ec9ab4145bfae33b308ffae1, type: 3} - target: {fileID: 5846939066456683150, guid: 31e12405ec9ab4145bfae33b308ffae1, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 6 value: 7
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 5846939066456683150, guid: 31e12405ec9ab4145bfae33b308ffae1, type: 3} - target: {fileID: 5846939066456683150, guid: 31e12405ec9ab4145bfae33b308ffae1, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
@ -2896,7 +2969,7 @@ PrefabInstance:
m_Modifications: m_Modifications:
- target: {fileID: 2662163039948621854, guid: 1da5e227ed55bcd4b943e0ceef78aefb, type: 3} - target: {fileID: 2662163039948621854, guid: 1da5e227ed55bcd4b943e0ceef78aefb, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 2 value: 3
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 2662163039948621854, guid: 1da5e227ed55bcd4b943e0ceef78aefb, type: 3} - target: {fileID: 2662163039948621854, guid: 1da5e227ed55bcd4b943e0ceef78aefb, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
@ -2969,7 +3042,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 7008207192594766311, guid: 2ed6bfce9ad3e19428cb9bef743e0fa3, type: 3} - target: {fileID: 7008207192594766311, guid: 2ed6bfce9ad3e19428cb9bef743e0fa3, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 1 value: 2
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 7008207192594766311, guid: 2ed6bfce9ad3e19428cb9bef743e0fa3, type: 3} - target: {fileID: 7008207192594766311, guid: 2ed6bfce9ad3e19428cb9bef743e0fa3, type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x

View File

@ -21,7 +21,6 @@ namespace Platforms
private void Update() private void Update()
{ {
if (!_collidingTriggerCheck.IsCollided || _onCollision) return; if (!_collidingTriggerCheck.IsCollided || _onCollision) return;
Debug.Log("On collision");
_onCollision = true; _onCollision = true;
StartCoroutine(Collapse()); StartCoroutine(Collapse());
} }
@ -34,7 +33,7 @@ namespace Platforms
private IEnumerator Collapse() private IEnumerator Collapse()
{ {
//changer sprite en rouge GetComponent<SpriteRenderer>().color = Color.red;
yield return new WaitForSeconds(TimeBeforeCollapse); yield return new WaitForSeconds(TimeBeforeCollapse);
ChangeState(false); ChangeState(false);
StartCoroutine(Reset()); StartCoroutine(Reset());
@ -45,7 +44,7 @@ namespace Platforms
{ {
yield return new WaitForSeconds(TimeBeforeReset); yield return new WaitForSeconds(TimeBeforeReset);
_onCollision = false; _onCollision = false;
//change sprite en normal GetComponent<SpriteRenderer>().color = Color.white;
ChangeState(true); ChangeState(true);
} }
} }

View File

@ -60,13 +60,13 @@ namespace Platforms
switch (_goingToFuturePos) switch (_goingToFuturePos)
{ {
case true: case true:
transform.position += new Vector3(0.05f, 0, 0); _platformRigidbody.AddForce(Vector2.left * 100.0f * Time.deltaTime, ForceMode2D.Impulse);
if (Math.Abs(_futurePos.x - transform.position.x) < VerificationOffset && if (Math.Abs(_futurePos.x - transform.position.x) < VerificationOffset &&
Math.Abs(_futurePos.y - transform.position.y) < VerificationOffset) Math.Abs(_futurePos.y - transform.position.y) < VerificationOffset)
_goingToFuturePos = false; _goingToFuturePos = false;
break; break;
case false: case false:
transform.position += new Vector3(-0.05f, 0, 0); _platformRigidbody.AddForce(Vector2.left * -100.0f * Time.deltaTime, ForceMode2D.Impulse);
if (Math.Abs(_originalPos.x - transform.position.x) < VerificationOffset && if (Math.Abs(_originalPos.x - transform.position.x) < VerificationOffset &&
Math.Abs(_originalPos.y - transform.position.y) < VerificationOffset) Math.Abs(_originalPos.y - transform.position.y) < VerificationOffset)
_goingToFuturePos = true; _goingToFuturePos = true;