[SOLVED] Shooting from Elemental Staff

Okay, sorry to bug you guys again. If I was to create an elemental staff within a model (it has no firing animation etc) what do I need to do in order to shoot from the staff in the straight line it’s been clicked on?

I’ve attached a Sphere Gameobject as a child of the staff, but I have no idea on what I need to do in order for when I click my mouse that it shoots that sphere.

If you guys have any tutorials, please do tell as I’m actually wanting to learn how Unity works!

Thanks

1 Answer

1

You could use Vector3.Lerp() to move the sphere from initial position to target position, over time.

The Unity manual page on prefab instantiation mentions a few methods for firing projectiles. You could look into adapting those to suit your purposes. When example scripts reference a “direction” for the shot, you can provide a direction by subtracting the target position from the shot origin – this will give you a vector pointing from one position to the other.