Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [RequireComponent(typeof(Rigidbody))]
- public class Projectile : MonoBehaviour
- {
- [SerializeField] private float _speed = 100f;
- [SerializeField] private Rigidbody _rigidbody;
- private void Reset() =>
- _rigidbody = GetComponent<Rigidbody>();
- public void Setup(Vector3 direction) =>
- transform.forward = direction.normalized;
- private void FixedUpdate() =>
- _rigidbody.velocity = transform.forward * (_speed * Time.deltaTime);
- }
Add Comment
Please, Sign In to add comment