I’m having a little brain racking problem, Basically i’m trying to determine the future position of an enemy object, now I think I have the code right in principle, however the Unity console is throwing up an error that I can’t seem to fix or have no idea of where to start.
Here is the code section: -
if (Vector3.Distance(Target.position, transform.position) <= RadarRange || Vector3.Angle(Target.position, transform.position) < 10)
{
var EnemySpeed = Target.GetComponent(FriendlyAI).InterceptSpeed;
var TargetFuturePosition : Vector3 = Target.position + EnemySpeed;
var FutureDirection : Vector3 = TargetFuturePosition - transform.position;
transform.Translate (0, 0, InterceptSpeed * Time.deltaTime);
var lookFutureRotation = Quaternion.LookRotation (FutureDirection);
transform.rotation = Quaternion.Slerp(rotation, lookFutureRotation, TurnSpeed * Time.deltaTime);
transform.Rotate (0,0, -angle * Roll);
IsIntercepting = true;
IsPatrolling = false;
IsEvading = false;
IsAttacking = false;
}
The problem is in the FutureTargetDirection variable, the Unity console is saying that I cannot use the operator + with the left hand side of type Vector 3 and the right hand side of float.
I don’t want to go down the road of rigidbodies since i’ve tried using them and they didn’t like how they acted in my game, so I decided to use transform.translate and rotation for movement.
I’ve tried changing the float to int and that came up with the same error.
Oh, I should also mention that EnemySpeed is taking a variable from the other enemy AI script.
Help?