Hi, I am currently trying to program an AI script in JavaScript and I decided to use itween for the walking between waypoints and it seems to not like my itween script section. The problem is in the function Update () section, specifically the 4 "if (waypointSelect == X) { ........}" Im really not that good at itween and i did try the tutorials for moveTo like iTween.MoveTo(gameObject{"y": 1, time: 1} ) but it wouldn't take it. So is there any way to alter the script where the problem is to make it do what i want it to do (go to the waypoints)?
var isShooting = false;
var isWalking = false;
var isNearPlayer = false;
var LookAtTarget : Transform;
var waypointSelect = 0;
var prefabBullet : GameObject;
var shootForce : float = 7000;
var Player : Transform;
var DistToPlayer : float;
var Waypoint1 : Transform;
var Waypoint2 : Transform;
var Waypoint3 : Transform;
var Waypoint4 : Transform;
function Shoot () {
var instanceBullet = Instantiate(prefabBullet, transform.position, transform.rotation);
instanceBullet.rigidbody.AddForce(transform.forward * shootForce);
}
function ShootIng () {
if (isShooting == true) {
transform.LookAt(LookAtTarget);
InvokeRepeating("Shoot", 1, 0.5);
}
else
{
CancelInvoke("Shoot");
}
}
function Walking () {
if (isWalking == true) {
waypointSelect = (Random.Range(1, 4));
}
}
function AIControl () {
if (isNearPlayer == true) {
Invoke("Shooting", 0.5);
WaitForSeconds (6);
Invoke("Walking", 0.5);
}
else
{
CancelInvoke("Shooting");
CancelInvoke("Walking");
}
}
function Update () {
if (Player) {
var dist = Vector3.Distance(Player.position, transform.position);
DistToPlayer = (dist);
}
if (waypointSelect == 1) {
iTween.MoveTo(Waypoint1);
}
if (waypointSelect == 2) {
iTween.MoveTo(Waypoint2);
}
if (waypointSelect == 3) {
iTween.MoveTo(Waypoint3);
}
if (waypointSelect == 4) {
iTween.MoveTo(Waypoint4);
}
if (DistToPlayer < 10) {
isNearPlayer = true;
}
else
{
isNearPlayer = false;
}
if (isNearPlayer == true) {
Invoke("AIControl", 0.5);
}
}