proto_top_down/Assets/Scripts/Projectile.cs

23 lines
480 B
C#

using UnityEngine;
[RequireComponent(typeof(Rigidbody2D))]
public class Projectile : MonoBehaviour
{
private Transform _transform;
private Rigidbody2D _rigidbody;
public float speed = 7;
private void Start()
{
_transform = transform;
_rigidbody = GetComponent<Rigidbody2D>();
_rigidbody.gravityScale = 0;
}
private void Update()
{
_transform.position += _transform.up * (speed * Time.deltaTime);
}
}