hey guys, i was coding AI for my multiplayer Game and i came across a problem, i got errors saying POSITION IS NOT A MEMBER OF UNITY.GAMEOBJECT
heres my script
i havent finished it yet because i couldn’t fix the problem
#pragma strict
public var WalkSpeed : float = 2;
public var RunSpeed : float = 5;
public var AviodDist : float = 2;
public var ShootNearDist : float = 4;
public var NearDist : float = 4.5;
public var FarShootDist : float = 6.4;
public var FarDist : float = 8;
private var Player : GameObject;
function Start () {
Player = GameObject.FindGameObjectWithTag("Player");
}
function Update () {
if(Vector3.Distance(transform.position,Player.position) <= AviodDist){
transform.position -= transform.forward*WalkSpeed*Time.deltaTime;
}
if(Vector3.Distance(transform.position,Player.position) <= NearDist){
NearTarget();
}
}
function NearTarget () {
transform.position += transform.forward*RunSpeed*Time.deltaTime;
if(Vector3.Distance(transform.position,Player.position) <= ShootNearDist){
}
}
function FindCover () {
}
function TakeCover () {
}
P.S i dont want C# code i need JS. because in C# you need to watch out more and you have to code more than JS.
var playerA : GameObject;
var playerB : playerA;
//playerB refers to the var PlayerA
//or if im wrong
var playerA : GameObject;
var playerB = playerA;
//playerB refers to the var PlayerA
i think i read about it in a javascript book so correct me if I’m wrong
i not really sure what you mean but this is what i can make sense of
*edit
ok i tried it and i didn’t work though
P.S if anyone is willing to help me provide a simple code example it would really help. or you can correct my code it would be helpful