I’m a begginer to unity and I’m making a simple FPS game and I have a problem with my shooting script.
I made several weapons (sub-machine gun, canon and pistol).
My problem is with the direction the bullet goes. It changes from gun to gun and I would like to have a default shooting script for every gun (if it’s possible ofcourse).
The problem I suspect is the vector positions are messed up ( transform.up in one makes it go forward and the other is (-negative)transform.up when I use AddForce):
Simplifying, I need to have one line of code that Adds force to all guns in the same direction.
(If it’s not possible, will creating new weapons in the same direction as the canon and sub-machine work?)
For the sub-machine and canon it works if I use: ===================================
Bala_Temp.AddForce(transform.up X ForcaDaBala);
for the pistol it works if I use: ===================================================
Bala_Temp.AddForce(-transform.up X ForcaDaBala);
(I put X instead of * because it would mess the bold)
Thanks in advance !
GameObject Cano_Temp; // (Cano_Temp is where the bullet shoots from) Cano_Temp = Instantiate(Bala,transform.position, transform.rotation) as GameObject; Rigidbody Bala_Temp; Bala_Temp = Cano_Temp.GetComponent<Rigidbody>(); //=====Problem is in the following lines below:===== //Bala_Temp.AddForce(-transform.up * ForcaDaBala);//pistol //Bala_Temp.AddForce(transform.up * ForcaDaBala);//canon and sub-machine