I am trying o shoot a bullet at the angle the Char faces.
I can shoot forward but if I am looking up for example then I want the bullet to fire forward and up , and vice versa for looking down.
I looked at past questions and didnt really get it. I also tried addforcerelative
Create a variable and call it dir1 (or whatever you want), then try using this code to define the variable:
var dir1;
var rot1 : int;
var rot2 : int;
var rot3 : int;
function Update () {
dir1 = Quaternion.Euler(rot1,rot2,rot3) * transform.forward;
Debug.DrawRay (transform.position, dir1, Color.green);
//example for you purposes
mybullet.AddForce(transform.forward * dir1);
}
This will create a direction that allows you to offset from the normal transform.forward (in other words a direction that’s pointing X degrees in the X direction). The rot1 is up and down, the rot2 is left to right, rot3 doesn’t do anything, you can just replace these variables with values too. You can also view the direction and edit in real-time while the game is playing.