Hello everyone, here is my problem:
I would like that when I press the A key
from the keyboard, a bullet is fired by the gun but the bullet does not fire, it just stays to the right and does not advance to the end of the map
The bullet code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ShootBullet : MonoBehaviour
{
public GameObject originalBullet;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if(Input.GetKeyDown("a"))
{
var bullet = Instantiate(originalBullet, transform.position, transform.rotation) as GameObject;
bullet.transform.Translate(Vector2.right * 20f * Time.deltaTime);
}
}
}
Thank you for your help !