Space Torpedo

What would be the best way to go about making a space torpedo like in trek films? I would also think there’s some kind of orb effect built in to unity that I can use? Any who I am all ears… any help is great, even documentation is fine. Been using C# as its like c++.

You havn’t given much on what features you want but ill tell you some structure to aim for to get started.

First make an empty gameobject, called Torpedo or w/e you want. Put its coordinates and rotation all to ZERO so you can orient it correctly.

Now create the effects you want, look at some tutorials on particles or models and put it as the child of the blank gameobject. This means the graphic and the object itself are separate and become much easier to change. Make sure this is at zero too. Also make sure its facing the Z axis because in your script you’ll probably use transform.forward to make movement and forward is the Z axis.

Add a script to the parent object called Torpedo (once again w/e you want). The simplest kind of torpedo goes straight. So make a public float variable called speed. In the Update function do something like this:

transform.Translate(transform.forward * Time.deltaTime * speed);

This means the torpedo will move forward at speed/second. Since it was public you can edit in the Unity editor now :slight_smile: If you want more advanced movement, edit how it moves here!

Drag this object into the folders window and it becomes a prefab. Look up how the Instantiate function works and in another script use that to create the missile at the point you want. Once its made it will fly straight at that speed.

But this will just go through walls and stuff. Add a collider to the parent, make a close shape to what you need, simpler the better then look up OnCollisionEnter(Unity - Scripting API: Collider.OnCollisionEnter(Collision))

This function gets called when the collider hits stuff so do whatever you need in that function, maybe checks to see what it hit and do accordingly.

This is the most basic way to make a torpedo/missile/bullet I can think of. Try this and play around, you’ll pick up and understand what you need to do next to make something cool :slight_smile:

Good luck!