- Home /
I get 2 errors in my AI script and 1 warning and can`t figure it out by myself..
(35,20): error CS1525: Unexpected symbol `else'
(52,1): error CS8025: Parsing error
(33,17): warning CS0642: Possible mistaken empty statement
using UnityEngine; using System.Collections;
public class AI1: MonoBehaviour {
public Vector3 Player;
public Vector2 PlayerDirection;
private float Xdif;
private float Ydif;
public Transform target;
public float speed;
public float rotatespeed = 5f;
private float rotZ;
private int Wall;
private float distance;
private bool stun;
private float stuntime;
void Start () {
stuntime = 0;
stun = false;
Wall = 1 << 8;
speed = 0.9f;
}
void Update () {
distance = Vector2.Distance (Player, transform.position);
Player = GameObject.Find("Player").transform.position;
if(stuntime > 0)(
stuntime -= Time.deltaTime)
else {
stun = false)
}
if (distance < 1.5 && !stun) {
Xdif = Player.x - transform.position.x;
Ydif = Player.y - transform.position.y;
PlayerDirection = new Vector2 (Xdif, Ydif);
if (!Physics2D.Raycast (transform.position, PlayerDirection, 3, Wall)) {
rigidbody2D.AddForce (PlayerDirection.normalized * speed);
}
rotZ = Mathf.Atan2 (Player.y, Player.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.LookRotation ((new Vector3 (0f, 0f, rotZ)));
}
}
}
void OnCollisionEnter2D (Collision2D Playerhit)(
if (Playerhit.gameobject.tag ("Player"){
stun = true;
stuntime = 1;
}
}
}
Comment
Start between lines 28 and 32 and look at the differences.
Answer by flaviusxvii · Jun 28, 2014 at 04:02 PM
Your code is a trainwreck of super basic syntax errors. Compilers aren't always super useful in giving meaningful errors. This takes some practice. I've fixed a section for you below..
This
if(stuntime > 0)(
stuntime -= Time.deltaTime)
else {
stun = false)
}
Should be
if(stuntime > 0) {
stuntime -= Time.deltaTime;
} else {
stun = false;
}
Your answer

Follow this Question
Related Questions
else, ||, and == aren't working.... 0 Answers
My script keeps getting an error 1 Answer
'else' not working.... please help:( 4 Answers
"Else" not working 2 Answers
Why am i getting this error?! 2 Answers