Hey! So im kind of new to unity i do understand the basics of coding and animations and much more. I have also made a few games that i actually enjoy playing. But i was curious
I found this unity project:
I downloaded the project and i wanted to make the plane shoot where the plane was pointing like you can see in the video ( the crosshair )
How do i make it shoot in scripts i have never done this before is there any tutorials you guys watched you mind sharing? Also later i will add an bomb that leaves the airplane but where the bomb lands depends on the speed i will probably make another thread on that.
Shooting can be easily implemented with raycasts. You cast imaginary ray from point given it direction and length and unity returns a collider the ray hit first or, if you want, list of all collider the ray penetrated. This collider is a place you will hit with you bullet. Next play shooting fx wait a little and play hit fx on the position where ray hit. You will have reference to the collider and game object of hit so you cado things like a collider.gameObject.GetComponent().acceptDamage(myGun.damage);
See Unity - Scripting API: Physics.Raycast for details and Unity - Scripting API: Physics for more options
As described above, shooting is easily done using raycasts. Since shooters in general are a very popular genre, you will find humongous tons of tutorials on that online. And whether you shoot from a plane or a gun does not really make a difference if you understand the concept behind it
As for the bomb, if the plane is a rigidbody, simply spawn the bomb under the plane and give it the same rigidbody velocity your plane has. That’s basically exactly what happens in reallife as well, and from there physics takes over and does the rest. If the plane is not a rigidbody, then you’ll need to calculate / remember the current velocity yourself instead.