Moving Platforms Improvement

This commit is contained in:
2022-02-26 11:10:26 +03:00
parent ea9da84b2e
commit bee004a425
3 changed files with 130 additions and 10 deletions

View File

@@ -95,5 +95,17 @@ namespace Platforms
return 0.0f;
}
private void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.CompareTag("Player"))
other.transform.SetParent(transform);
}
private void OnCollisionExit2D(Collision2D other)
{
if (other.gameObject.CompareTag("Player"))
other.transform.SetParent(null);
}
}
}
}