1
Fork 0
mirror of https://github.com/Steffo99/keep-everything-alive.git synced 2024-11-25 10:44:18 +00:00
keep-everything-alive/Assets/Scripts/Microgame_Earth/MoveRandomly.cs
2020-04-19 17:55:44 +02:00

21 lines
604 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Rigidbody2D))]
public class MoveRandomly : MonoBehaviour
{
public float forceMultiplier = 3f;
public float torqueMultiplier = 30f;
private new Rigidbody2D rigidbody2D;
void Awake() {
rigidbody2D = GetComponent<Rigidbody2D>();
}
void Start() {
rigidbody2D.AddForce(new Vector3(Random.value - 0.5f, Random.value - 0.5f, 0).normalized * Random.value * forceMultiplier);
rigidbody2D.AddTorque((Random.value - 0.5f) * 2f * torqueMultiplier);
}
}