I have a projectile set up to go to an ‘end point’ once it is fired. I’m using an example found:
delta = target.transform.position - transform.position;
delta.Normalize();
travelSpeed = speed * Time.deltaTime;
transform.position = transform.position + (delta * travelSpeed);
Now this code does work, but when the target moves the projectiles still all go to the original position of the target. I have the target object parented to my character controller so that when the player moves right or left the target follows on the x-axis. I wanted the projectiles to go the then target no matter where it was on the x-axis. I had it working a few days ago and for the life of me I can’t remember what I did or if it was part of the code I listed above. Anyone have any thoughts/info?
Thank you
not sure if anyone was interested in this haha! However, I did get it to work by just eliminating the:
" - transform.position "
So now when you fire it will go to the last known position of the target when you hit the button.
I used it for a projectile. I found it in some example code. once it is fired, this code will take the projectile and go to a ‘target’ location. So basically you have a target and you want the projectile to go to it. Almost like a starting point and ending point, the start would be the place where the projectile is instantiated and the end would be the location of the target.
Why the “smart” projectile thou???
I thought it might have been easier to do that instead of trying to figure out what kind of angle to fire at. I needed a projectile to appear to go ‘up’, but in actuality is is going up at an angle.