Skip to content

Commit

Permalink
#601 make clouds move
Browse files Browse the repository at this point in the history
  • Loading branch information
shieldgenerator7 committed Jul 30, 2024
1 parent 8d286ca commit 551d4a4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions Assets/Scripts/Mechanics/CloudMover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using UnityEngine;

[RequireComponent(typeof(GravityAccepter))]
[RequireComponent (typeof(Rigidbody2D))]
[RequireComponent(typeof(Rigidbody2D))]
public class CloudMover : MonoBehaviour
{
public float speed = 0.02f;
Expand All @@ -21,6 +21,9 @@ void Start()
// Update is called once per frame
void FixedUpdate()
{
rb2d.velocity = gravityAccepter.SideVector * speed;
Vector2 center = Vector2.zero;// gravityAccepter.Center.position //TODO: use gravityAccepter center
Vector2 gravityVector = center - (Vector2)transform.position;
Vector2 sideVector = new Vector3(-gravityVector.y, gravityVector.x) / Mathf.Sqrt(gravityVector.x * gravityVector.x + gravityVector.y * gravityVector.y);
rb2d.velocity = sideVector.normalized * speed;
}
}

0 comments on commit 551d4a4

Please sign in to comment.