- Home /
Shoot Projectile Where Camera Faces [PLEASE HELP!]
So Im making a multiplayer game, and Im trying to make the player shoot a fire ball.That part is easy, however I dont want it to just shoot a fireball in a straight line forward, I want it to be that if whereever the player looks it will shoot a projectile at that angle. (Ex: If im looking 45 degrees in the air trying to shoot a bird or whatever, I want it too shoot at an angle not just forward in front of my player)
GameObject fireball = (GameObject)PhotonNetwork.Instantiate("Fireball",transform.position,transform.rotation,0);//Instantiate fireball
fireball.rigidbody.AddForce(transform.forward * 600); //make it move
Answer by kurotatsu · Sep 16, 2014 at 05:43 AM
I used to put a mouselook script on my shooter empty that was set up the same as the one on my camera, or wrote a script that matched my camera's rotation to achieve this.
Just some food for thought.
Answer by philwinkel · Dec 27, 2014 at 05:10 PM
fireball.rigidbody.AddForce(transform.forward * 600); //make it move
this is why is shooting straight from your player - transform.forward is straight from your player.
you need to shoot it from the camera, or the direction your player is looking.
Your answer
![](https://koobas.hobune.stream/wayback/20220613163107im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Unity Photon syncing objects 0 Answers
Need help... Start Button no longer working!!!!! 0 Answers
FPS Multiplayer setup - TPS models for other clients 1 Answer