2D Shooter, Need help with shooting in the direction I am facing

Updated on January 14, 2018 in [A] Tutorials
Share on Facebook0Tweet about this on TwitterShare on Google+0Share on Reddit0
1 on January 11, 2018

I am currently working on a 2D shooter game and need help with shooting in the direction I am facing. I am following Brackeys shooting tutorial but need to change shooting in the mouses direction to the direction I am facing.

  • Liked by
0 on January 14, 2018

Hi here : 

MyProjectile = (GameObject)Instantiate(MyProjectilePrefab, tranform.position + new Vector3(0.0f, 0.0f, 0.0f), Quaternion.Euler(0f, 0f, 0f); 

You must create a prefab here i named it :MyProjectilePrefan . transform.position is used to throw it from the position of the gameobject using projectile . new Vector3(..) is used to move the projectile from the position to not let it instantiate in you gameobject (it’s better if it goes from the forward) . Quaternion.Euler(..) is used to turn the projectile (let everything to 0 if you don’t want any rotation of the projectile.

  • Liked by