OK, I spent some time coding up a solution for you. This uses exactly the technique I suggested above.
First, let’s start with the straight (non-arcing) projectile. Here’s a complete script.
using UnityEngine;
public class ArcingProjectile : MonoBehaviour {
public Transform target;
public float speed = 5;
float startDist;
void Start() {
}
void Update() {
// Look at the target, so we continue to seek it out
transform.LookAt(target);
// Move forward
transform.Translate(Vector3.forward * speed * Time.deltaTime);
}
}
So, we look at the target, and move forward. You had this much already, though you never posted a complete script. Now let’s modify it to, as I suggested, compute an arc based on how far along the path we are. I’m using Lerp (actually LerpAngle) here because it’s probably the easiest to understand and tweak.
using UnityEngine;
public class ArcingProjectile : MonoBehaviour {
public Transform target;
public float speed = 5;
float startDist;
void Start() {
// Find the initial distance to the target
startDist = (target.transform.position - transform.position).magnitude;
}
void Update() {
// Look at the target, so we continue to seek it out
transform.LookAt(target);
// Compute the distance to the target
float dist = (target.transform.position - transform.position).magnitude;
// ...and the fraction (t) of how far we are along the path
float t = Mathf.Clamp01(1 - (dist / startDist));
// Use this to arc (rotate up) the projectile
float arc = Mathf.LerpAngle(-30, 0, t);
transform.Rotate(arc, 0, 0);
// Move forward
transform.Translate(Vector3.forward * speed * Time.deltaTime);
}
}
I’ve tested this and it works great for me. If it doesn’t work great for you, please post a detailed description of what you did, what happened, and how that differed from what you wanted.
And finally, please take note of what sort of community we have here. Unlike most forums on the Internet, the Unity forums are a very friendly place. We don’t swear at each other; we don’t do personal attacks; we give support and encouragement as much as we can, and thoughtful criticism when it is asked for. Most of us are professionals who have our own projects we should be working on; we hang out here to be part of the community and help newbies to repay the karma from those who helped us.
If you’re struggling with something, and observe lots of people making suggestions and you can’t get them to work, consider that you probably don’t have the necessary background to make them work, or your basic assumptions are somehow flawed. Getting angry and antangonizing those who try to help you is not productive. Asking more questions is, if you ask calmly, include lots of detail, and show a willingness to try what is suggested.
OK, enough soapboxing from me… I hope this is helpful, and I look forward to seeing the amazing games you create someday!