Updated platform scripts
This commit is contained in:
@@ -21,7 +21,6 @@ namespace Platforms
|
||||
private void Update()
|
||||
{
|
||||
if (!_collidingTriggerCheck.IsCollided || _onCollision) return;
|
||||
Debug.Log("On collision");
|
||||
_onCollision = true;
|
||||
StartCoroutine(Collapse());
|
||||
}
|
||||
@@ -34,7 +33,7 @@ namespace Platforms
|
||||
|
||||
private IEnumerator Collapse()
|
||||
{
|
||||
//changer sprite en rouge
|
||||
GetComponent<SpriteRenderer>().color = Color.red;
|
||||
yield return new WaitForSeconds(TimeBeforeCollapse);
|
||||
ChangeState(false);
|
||||
StartCoroutine(Reset());
|
||||
@@ -45,7 +44,7 @@ namespace Platforms
|
||||
{
|
||||
yield return new WaitForSeconds(TimeBeforeReset);
|
||||
_onCollision = false;
|
||||
//change sprite en normal
|
||||
GetComponent<SpriteRenderer>().color = Color.white;
|
||||
ChangeState(true);
|
||||
}
|
||||
}
|
||||
|
@@ -60,13 +60,13 @@ namespace Platforms
|
||||
switch (_goingToFuturePos)
|
||||
{
|
||||
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 &&
|
||||
Math.Abs(_futurePos.y - transform.position.y) < VerificationOffset)
|
||||
_goingToFuturePos = false;
|
||||
break;
|
||||
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 &&
|
||||
Math.Abs(_originalPos.y - transform.position.y) < VerificationOffset)
|
||||
_goingToFuturePos = true;
|
||||
|
Reference in New Issue
Block a user