Enemy throwing projectiles in an arc
Hi everyone. I'm pretty new to Unity and C# so I would be extremely grateful if you could help me with something.
I'm trying to have an enemy shoot projectiles up in the air in an arc in 2D repeatedly. I've tried looking at the API and using a script someone else referenced but I've had no luck thusfar. I know how to spawn the projectile from an empty gameobject, I'm just really stuck on the throwing part. Here's what I've got:
using UnityEngine;
using System.Collections;
public class Handcuffs : MonoBehaviour {
public float thrust;
public Rigidbody2D rb;
void Start() {
rb = GetComponent<Rigidbody2D>();
}
void FixedUpdate() {
rb.AddForce(transform.forward * thrust);
}
}
However it doesn't do anything no matter which thrust value I assign it. Any tips would be much appreciated, thank you.
Answer by kellerr112 · Jan 20, 2016 at 03:24 PM
You have a few options. If you want true curves, you're going to have to look into splines. If you're fine with fake curves, you can set multiple points for the projectile to visit before it hits the intended target.
Thanks for the answer. Is there no way to throw the projectile into the air at a certain angle and then simply have it fall down with gravity?