/* Check if the ground overlaps with any gameobjects on the "Ground" Layer, * if so the if the collider is a MovingPlatform return its velocity */ private Vector2 GetPlatformMovement() { Collider2D collider = Physics2D.OverlapCircle(GroundCheck.position, 0.3f, GroundLayer); if (collider != null && collider.GetComponent <MovingPlatform>() != null) { // Get the platform's controller MovingPlatform platform = collider.gameObject.GetComponent <MovingPlatform>(); // Get the platform's movement from the controller return(platform.GetMovement()); } return(Vector2.zero); }