27 lines
530 B
C#
Raw Normal View History

2020-03-05 00:48:39 +01:00
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()
{
2020-03-11 21:11:27 +01:00
rb.velocity = transform.right * _speed.Value;
2020-03-05 00:48:39 +01:00
}
}