So I’m working on a game with gameplay similar to Kid Icarus Uprising, and I need to figure out how to get the projectiles to fire towards a reticle gameobject. I already have the reticle tracking the mouse position, as well as the projectiles themselves spawning, but I need help getting them to fire towards the reticle’s current position.
Right now this is what I have:
public class FireProjectileAtCursor : MonoBehaviour {
public Object Projectile;
public Transform fireAnchor;
public float fireSpeed = 20.0f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void FixedUpdate () {
if (Input.GetButtonDown ("Fire1"))
{
Instantiate (Projectile, fireAnchor.position, fireAnchor.rotation);
}
}
}
So I don’t actually have the projectile firing towards anything at the moment.
The only script on the projectile itself just spawns particle effects and destroys the object on collision. This script is attached to the player.