mirror of
https://github.com/unity-atoms/unity-atoms.git
synced 2025-01-24 17:17:47 -05:00
27 lines
530 B
C#
27 lines
530 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityAtoms.BaseAtoms;
|
|
|
|
[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<Rigidbody2D>();
|
|
rb.isKinematic = true;
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
rb.velocity = transform.right * _speed.Value;
|
|
}
|
|
}
|