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

@@ -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);
}
}

View File

@@ -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;