x


CS8025 Parsing error

Im getting an error that says: Assets/Scripts/EnemyAI.cs(35,9): error CS8025: Parsing error and i dotn know whats causing it so please help me :)

here is my code: using UnityEngine; using System.Collections;

public class EnemyAI : MonoBehaviour { public Transform target; public int moveSpeed; public int rotationSpeed; public int maxDistance;

private Transform myTransform;

void Awake() {
    myTransform = transform;

}

// Use this for initialization
void Start () {
    GameObject go = GameObject.FindGameObjectWithTag("Player");

    target = go.transform;

    maxDistance = 2;

}

// Update is called once per frame
void Update () {
    Debug.DrawLine(target.position, myTransform.position, Color.yellow);

    //Look at target
    myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed * Time.deltaTime);

    if(Vector3.Distance(target.position, myTransform.position) > maxDistance) {
        //move towards target
        myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
    }
}
more ▼

asked Jan 29 '11 at 02:18 PM

mido555 gravatar image

mido555
74 8 8 14

Sorry this is wrong turns out it was a unity error i restarted unity and now it works fine :)

Jan 29 '11 at 02:23 PM mido555
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first
public class EnemyAI : MonoBehaviour 
{
    // ...

    void Awake() 
    {
        // ...
    }

    void Start () 
    {
        // ...
    }

    void Update () 
    {
        // ...
    }

} // <- You are missing one of these.

Reformatting the code so it's easier to read shows that you are missing a curly bracket to close the class.

more ▼

answered Jan 29 '11 at 02:25 PM

Statement gravatar image

Statement
25.3k 41 78 197

thanks i already found that out after looking there and saying to my self "hmm should i put curly brackets there?" for 5 mins but thanks anyway :)

Jan 30 '11 at 11:10 AM mido555
(comments are locked)
10|3000 characters needed characters left

I need help My program wont work! This is it

using UnityEngine;

using System.Collections;

public class shooter : MonoBehaviour {

public Rigidbody bullet;

public float power = 1500f;

public float moveSpeed = 2f;

void Update () {

    float h = Input.GetAxis("Horizontal") * Time.deltaTime * moveSpeed;


    float v = Input.GetAxis("Vertical") * Time.deltaTime * moveSpeed;


    transform.Translate(h, v, 0);

    if(Input.GetButtonUp("Fire1")){

       Rigidbody instance = Instantiate(bullet, transform.Position, transform.Rotation) as Rigidbody;


       Vector3 fwd = transform.TransformDirection(Vector3.forward);


       instance.AddForce(fwd * power);
}

}

more ▼

answered Mar 10 '13 at 05:26 AM

koby2010 gravatar image

koby2010
0

(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:

x2986
x69
x39

asked: Jan 29 '11 at 02:18 PM

Seen: 11549 times

Last Updated: Mar 10 '13 at 05:26 AM