x


AI Follow Player "Tag" Help

Hi Guys! i have a Problem. I made a Script. but i get 5 Errors i know it's kinda of a Chain Error. The Script is Right HERE

  1. Assets/Scripts/EnemyAI.cs(13,24): error CS1061: Type UnityEngine.GameObject' does not contain a definition forposition' and no extension method position' of typeUnityEngine.GameObject' could be found (are you missing a using directive or an assembly reference?)

  2. Assets/Scripts/EnemyAI.cs(13,36): error CS1061: Type UnityEngine.GameObject' does not contain a definition forposition' and no extension method position' of typeUnityEngine.GameObject' could be found (are you missing a using directive or an assembly reference?)

  3. Assets/Scripts/EnemyAI.cs(13,12): error CS1502: The best overloaded method match for `UnityEngine.Vector3.Distance(UnityEngine.Vector3, UnityEngine.Vector3)' has some invalid arguments

  4. Assets/Scripts/EnemyAI.cs(13,12): error CS1503: Argument #1' cannot convertobject' expression to type `UnityEngine.Vector3'

  5. Assets/Scripts/EnemyAI.cs(14,9): error CS0029: Cannot implicitly convert type UnityEngine.GameObject' toUnityEngine.Transform'

more ▼

asked Apr 24 '12 at 06:59 PM

Nahoyman78 gravatar image

Nahoyman78
35 5 12 13

Well, looks like you need to define the position variable, for start.

Apr 24 '12 at 10:07 PM CC Inc
(comments are locked)
10|3000 characters needed characters left

1 answer: sort oldest

Here you're trying do mix types GameObject and Transform:

target = go;

try:

target = go.transform;
more ▼

answered Apr 24 '12 at 10:12 PM

GutoThomas gravatar image

GutoThomas
593 32 46 47

Awsome Thanks! :D

Apr 25 '12 at 12:31 PM Nahoyman78

But i still get errors :( Any Ideas?

Apr 25 '12 at 12:33 PM Nahoyman78

What kind of error are you getting?

Apr 25 '12 at 01:02 PM GutoThomas

Ah, I forget about something, sorry.

void  Update (){

GameObject go = GameObject.FindGameObjectWithTag("Player");

if(Vector3.Distance(go.position,go.position)<minRange)

You're trying to access the distance of the go without refer his transform. It should work if you change to:

if(Vector3.Distance(go.transform.position,go.transform.position)<minRange)
Apr 25 '12 at 01:11 PM GutoThomas

OMG! THANKS!

Apr 25 '12 at 02:03 PM Nahoyman78
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1953
x1951
x960
x806
x324

asked: Apr 24 '12 at 06:59 PM

Seen: 714 times

Last Updated: Apr 25 '12 at 02:03 PM