using UnityEngine;
using UnityAtoms.BaseAtoms;
namespace UnityAtoms.Examples
{
///
/// Sets a constant velocity on the attached Rigidbody 2D.
///
[RequireComponent(typeof(Rigidbody2D))]
public class MoveInDirection : MonoBehaviour
{
public float Speed { set => _speed.Value = value; }
[SerializeField]
private FloatReference _speed;
private Rigidbody2D rb;
void Start()
{
rb = GetComponent();
rb.isKinematic = true;
}
void Update()
{
rb.velocity = transform.right * _speed.Value;
}
}
}