Push for Syn

This commit is contained in:
OverflowNarhoym
2022-02-25 20:14:54 +01:00
parent 805aeb2d82
commit 75ea014fbf
4 changed files with 109 additions and 63 deletions

View File

@@ -140,7 +140,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_LocalPosition.y
value: -2.1712146
value: -12.44
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349113, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_LocalPosition.z
@@ -176,7 +176,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349115, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_BodyType
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349115, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_Constraints
@@ -190,6 +190,18 @@ PrefabInstance:
propertyPath: m_GravityScale
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349115, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_CollisionDetection
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349117, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: speed
value: 0.05
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349117, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: xOffset
value: 5
objectReference: {fileID: 0}
- target: {fileID: 3453266731971349118, guid: 821831f062ee52848b6bda27fba0b001, type: 3}
propertyPath: m_Name
value: Moving_Platform_Medium
@@ -2967,6 +2979,14 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 2662163039882375472, guid: 1da5e227ed55bcd4b943e0ceef78aefb, type: 3}
propertyPath: m_LocalPosition.x
value: 14.936234
objectReference: {fileID: 0}
- target: {fileID: 2662163039882375472, guid: 1da5e227ed55bcd4b943e0ceef78aefb, type: 3}
propertyPath: m_LocalPosition.y
value: -8.049541
objectReference: {fileID: 0}
- target: {fileID: 2662163039948621854, guid: 1da5e227ed55bcd4b943e0ceef78aefb, type: 3}
propertyPath: m_RootOrder
value: 3
@@ -3019,6 +3039,14 @@ PrefabInstance:
propertyPath: m_Follow
value:
objectReference: {fileID: 1053905692}
- target: {fileID: 2662163040849090937, guid: 1da5e227ed55bcd4b943e0ceef78aefb, type: 3}
propertyPath: m_LocalPosition.x
value: 14.936234
objectReference: {fileID: 0}
- target: {fileID: 2662163040849090937, guid: 1da5e227ed55bcd4b943e0ceef78aefb, type: 3}
propertyPath: m_LocalPosition.y
value: -8.049541
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 1da5e227ed55bcd4b943e0ceef78aefb, type: 3}
--- !u!1001 &7008207193554258683
@@ -3040,17 +3068,21 @@ PrefabInstance:
propertyPath: m_Name
value: Player
objectReference: {fileID: 0}
- target: {fileID: 7008207192594766310, guid: 2ed6bfce9ad3e19428cb9bef743e0fa3, type: 3}
propertyPath: m_Enabled
value: 1
objectReference: {fileID: 0}
- target: {fileID: 7008207192594766311, guid: 2ed6bfce9ad3e19428cb9bef743e0fa3, type: 3}
propertyPath: m_RootOrder
value: 2
objectReference: {fileID: 0}
- target: {fileID: 7008207192594766311, guid: 2ed6bfce9ad3e19428cb9bef743e0fa3, type: 3}
propertyPath: m_LocalPosition.x
value: 0
value: 8.4
objectReference: {fileID: 0}
- target: {fileID: 7008207192594766311, guid: 2ed6bfce9ad3e19428cb9bef743e0fa3, type: 3}
propertyPath: m_LocalPosition.y
value: 0
value: -10.04
objectReference: {fileID: 0}
- target: {fileID: 7008207192594766311, guid: 2ed6bfce9ad3e19428cb9bef743e0fa3, type: 3}
propertyPath: m_LocalPosition.z

View File

@@ -8,6 +8,7 @@ namespace Platforms
{
public float xOffset;
public float yOffset;
public float speed;
private Vector3 _originalPos;
private Vector3 _futurePos;
@@ -29,7 +30,7 @@ namespace Platforms
_goingToFuturePos = true;
}
private void Update()
private void FixedUpdate()
{
if (!IsPaused)
Move(BaseSpeed);
@@ -57,21 +58,37 @@ namespace Platforms
public void Move(float value)
{
var position = transform.position;
switch (_goingToFuturePos)
{
case true:
_platformRigidbody.AddForce(Vector2.left * 100.0f * Time.deltaTime, ForceMode2D.Impulse);
_platformRigidbody.MovePosition(new Vector2(position.x + speed * GetDecision(xOffset),
position.y + speed * GetDecision(yOffset)));
if (Math.Abs(_futurePos.x - transform.position.x) < VerificationOffset &&
Math.Abs(_futurePos.y - transform.position.y) < VerificationOffset)
_goingToFuturePos = false;
break;
case false:
_platformRigidbody.AddForce(Vector2.left * -100.0f * Time.deltaTime, ForceMode2D.Impulse);
_platformRigidbody.MovePosition(new Vector2(position.x + speed * -GetDecision(xOffset),
position.y + speed * -GetDecision(yOffset)));
if (Math.Abs(_originalPos.x - transform.position.x) < VerificationOffset &&
Math.Abs(_originalPos.y - transform.position.y) < VerificationOffset)
_goingToFuturePos = true;
break;
}
}
private static float GetDecision(float value)
{
switch (value)
{
case < 0:
return -1.0f;
case > 0:
return 1.0f;
}
return 0.0f;
}
}
}