public GameObject projectile;
public Rigidbody rb;
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.LeftShift))
{
GameObject bullet = Instantiate(projectile, transform.position, Quaternion.identity) as GameObject;
bullet.GetComponent().AddForce(transform.forward * 10);
}
}
Hi Leisure, your problem is not clear. I think the problem is that the bullet always move along the global up. And you want it to move in the direction it is facing. If that the case then you can assign a script to the bullet where you move it using the code transform.Translate(Vector2.Up, Space.Self);
what this code does is that it moves the bullet in the upward vector relative to its own position.
And remember to parent that bullet after instantiation to a gameobject that doesnt move or it will continue to persue its parent horizontal position.