#Bullet goes only to one side

1 messages · Page 1 of 1 (latest)

shut smelt
#
    {
        float velocity = bulletVelocity * Time.deltaTime;

        if(Input.GetMouseButtonDown(0))
        {
            GameObject bulletPrefab_ = Instantiate(bulletPrefab, new Vector3(firePos.position.x, firePos.position.y, firePos.position.z), firePos.rotation);
            bulletPrefab_.GetComponent<Rigidbody>().velocity = velocity * transform.forward;
        }
    }
stone hearth
#

Why are you using transform.forward instead of firePos.forward to set the velocity?

Also, multiplying the velocity with deltaTime logically makes no sense.

And you don't need to create a new Vector3 in the Instantiate call; you can simply pass in firePos.position directly.

shut smelt
#

thank you, works like a charm now

shut smelt
#

i changed up some stuff and added a flashlight n stuff but now this is what happens when i shoot with the gun equipped

#

everything seems correct for me, yet it dont work