i want to shoot in diferent angles than my character is facing

Uh boy this is a tough one… seriously i dont trust in my ability to explain this because is very confusing so i made a video showing what is going wrong with my game

here it is > http://www.youtube.com/watch?v=ovz8rcDuego

but even so, im gonna try to explain…

i need to make the character shoot plasma balls… so i decided to make a " shoot point" , a game object that was supose to be invisible and attached to the character’s arm, so when the player hits fire button, a prefab plasma ball will spawn at that shoot point and then i add some force to the prefab in the forward direction… he would be sent flying in that direction…

now… what does unity undestand by “forward”?.. because later i made a feature that allows the player to aim up and down… you know… like an fps game… but when you shoot, the plasma ball keeps going only at the horizontal plane, i mean… it spawns ok, from the edge of the characters arm… but then it does not fly to where the arm is pointing, instead, it just flies forward in the direction the characters body is facing

what? o.o

heres my code

f ( Input.GetButtonDown ("shoot")) { 

shooting = true;

animation.Rewind("shoot"); 
animation.Play("shoot"); 


var bullit = Instantiate (fireball,GameObject.Find("shootpoint").transform.position,Quaternion.identity);

bullit.rigidbody.AddForce (transform.forward * 1300) ;

}

edit : in the video, you can see the shootpoint i mentioned, because i rendered it so i could better explain… its a gray ball in the character’s arm

i knew this would be impossible to explain >.<

look… i got another idea…

in a FPS, how does the script determinate where the projectil is going? because is where you pointing right? thats what i want to do but without the mouse…

ok that made everthing so more complicated… forget this reply… focus on the question above plz

I’m being lazy and not looking up the API for instantiate but it looks like you are instantiating with rotation set to:

Quaternion.identity

which effectively means don’t rotate. If this script is attached to the player not the shooting point (as suggested by the GameObject.Find(“shootpoint”)) then it seems like pretty reasonable behaviour for it to shoot in the direction the player is facing.

Your best bet is to work out the behaviour of Instantiate by reading the API’s, or by experimentation (or both). Then update the quarternion for the rotation to correspond to the shooting points direction.

The shootpoint object needs to be a child of the arm, so it adopts all position and rotations of the parent/arm. When making an fps I parent a gun mesh to the camera, then parent a shootpoint to the gun, usually just beyond the tip of the muzzle. So no matter what direction I’m looking in, the gun will always fire towards the center of the screen.

Take a look at the video on my portfolio site for a method I used sdunne

//Point Bullets are insantiated atpublic var bulletPoint : GameObject;// - Pastebin.com here’s the code

You could use a smooth look at script on the dudes arms so they’re always pointing at the hit point. Also here’s some code to get rid of Unitys horribly choppy mouselook controls http://pastebin.com/EDpVKUUv Camera movement smoothing is the bit about fixing mouselook, but you can use the aim assist or anything else too if you want.

whoa this is way too pro for me…

i apreciate the help fourthings but i think you misundestood my abilities… im very noob at javascript… and with raycasting scripts, im just hopeless… soo… even taking a hard look on your script and in the coments i still have no idea man… sorry…

… well… it seems both of you jhonnyA and Fourthings undestood what i was talking about… since the shooting script is attached to the player… when i instantiate the projectile and tell quim to go quaternion.identity, he will aways stay in the same angle as the main body of the character… so you guys think that my best move would be changing the script to the shoot point? so that way, when the character moves his arm and the shootpoint attached to his arms moves too… the quaternion.identity will still work because he will capture the exact angle the shootpoint is ?

hey… i think i came up with a solution o.O

EDIT: no i didnt work… look i think it would be much easier if some could just give me a cool code that stores the angles that a gameobject is facing… i mean… we have quaternion,identity, that is a code that stores the angle of the gameobject the script is attached to… but… is there any quaternion.other identities?.. because if there is… i can make the projectile be instantiate from the angles of the shootpoint instead

Use the “shoot point”'s transform.rotation instead of Quaternion.identity.

You rock!!

it worked!! yhea!