Help!

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.

Player is a GameObject, position is a part of Transform.

Use Player.transform.position;

if i do that than the line here

    Player = GameObject.FindGameObjectWithTag("Player");

would fail.

can you do transform.FindObject With tag something like that?

i tried to do something familiar but it failed

what i want is the script to find an object tagged as Player and the rest of the script would do its thing

You can find the GameObject as you have.
Then just set up a var to represent the Transform of that object.
Pass the gameObject into the transform var.

use playerTransfrom.posiiton = xyz;

if i were going to put that in the script how would i code it

if you put a code sample it will be easier to understand what you mean

ok so is it like

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

hello?

Wow, i have no idea what the hell you are doing.

The error is because you are doing this:

 if(Vector3.Distance(transform.position,Player.position) <= NearDist){

See the Player.position it has to be Player.transform.position

 if(Vector3.Distance(transform.position,Player.transform.position) <= NearDist){

Same as

    if(Vector3.Distance(transform.position,Player.position) <= ShootNearDist){

should be
[ccode]
if(Vector3.Distance(transform.position,Player.transform.position) <= ShootNearDist){
[/code]

and

  if(Vector3.Distance(transform.position,Player.position) <= AviodDist){

should be

  if(Vector3.Distance(transform.position,Player.transform.position) <= AviodDist){

oh, drat

i thought the Player.transform.position was still recognized as a transform.

thanks Elite Mossy!