I understand what you said a little bit, but I'm having trouble trying to implement it. I moved the shooting stuff and now the bullets just spawn and sit. From the tips you gave it sounds like I'm supposed to call something in the Bullet script, but I don't know what. I decided to use the old input system for getting keys pressed because the new one is just giving me trouble. My player is the one shooting the bullets, here is the code that I have for the Player script
using UnityEngine; using UnityEngine.InputSystem; public class PlayerController : MonoBehaviour { [SerializeField] float runspeed = 10f; [SerializeField] GameObject bullet; [SerializeField] Transform gun; [SerializeField] float bulletSpeed = 10f; [SerializeField] float fireDelay; private float lastFire; Vector2 moveInput; Rigidbody2D myRigidbody; Rigidbody2D bulletRigidBody; bool isAlive = true; void Start() { myRigidbody = GetComponent<Rigidbody2D>(); } void Update() { if(!isAlive) { return; } Run(); if(Time.time > lastFire + fireDelay) { return; } Fire(); } void OnMove(InputValue value) { moveInput = value.Get<Vector2>(); } void Run() { Vector2 playerVelocity = new Vector2 (moveInput.x * runspeed, moveInput.y * runspeed); myRigidbody.velocity = playerVelocity; } void OnShoot(InputValue value) { if(!isAlive) { return; } Instantiate(bullet, gun.position, transform.rotation); } void Fire() { if (Input.GetKey(KeyCode.UpArrow)) { Shoot(Vector2.up); lastFire = Time.time; } else if (Input.GetKey(KeyCode.RightArrow)) { Shoot(Vector2.right); lastFire = Time.time; } else if (Input.GetKey(KeyCode.DownArrow)) { Shoot(Vector2.down); lastFire = Time.time; } else if (Input.GetKey(KeyCode.LeftArrow)) { Shoot(Vector2.left); lastFire = Time.time; } } void Shoot(Vector2 direction) { bulletRigidBody.velocity = new Vector2(direction.x * bulletSpeed, direction.y * bulletSpeed); } } // the text after this comment is the code in my Bullet script using UnityEngine; public class Bullet : MonoBehaviour { private void OnTriggerEnter2D(Collider2D other) { if(other.tag == "Enemy") { Destroy(other.gameObject); } Destroy(gameObject); } private void OnCollisionEnter2D(Collision2D other) { Destroy(gameObject); } }