| 12345678910111213141516171819202122232425262728293031 |
- using UnityEngine;
- using UnityEngine.InputSystem;
- public class Projectile : MonoBehaviour
- {
- public GameManager gameManager;
- public float speed = 1;
- public Vector3 direction = Vector3.zero;
- // Start is called once before the first execution of Update after the MonoBehaviour is created
- void Start()
- {
- if (gameManager == null)
- {
- gameManager = FindFirstObjectByType<GameManager>();
- }
- }
- // Update is called once per frame
- void Update()
- {
- transform.position = transform.position + direction.normalized * speed;
- }
- public void SetValues(float speed, Vector3 direction)
- {
- this.speed = speed;
- this.direction = direction;
- }
- }
|