- Home /
Parsing error Terror!
for some reason I get a parsing error on the last line of this script, and I cant figure out whats wrong with it!
using UnityEngine; using System.Collections;
public class EnemyAttack : MonoBehaviour { public GameObject target; public float attacktimer; public float cooldown;
// Use this for initialization void Start () { attacktimer = 0; cooldown = 1; }
// Update is called once per frame void Update () { if(attacktimer > 0) attacktimer -= Time.deltaTime;
if(attacktimer < 0)
attacktimer = 0;
if(attacktimer == 0)
Attack();
attacktimer = cooldown;
}
private void Attack() { float distance = Vector3.Distance(target.transform.position, transform.position);
Vector3 dir = (target.transform.position - transform.position).normalized;
float direction = Vector3.Dot(dir, transform.forward);
if(distance < 3) { if(direction > 0){
EnemyHealth eh = (EnemyHealth)target.GetComponent("EnemyHealth"); eh.AddjustCurrentHealth(-5); } }
}
Answer by Maarten · Dec 12, 2010 at 01:20 AM
You need to change:
if(attacktimer == 0)
Attack();
attacktimer = cooldown;
To:
if(attacktimer == 0)
{
Attack();
attacktimer = cooldown;
}
You can only write one single line of code, without using braces in an if statement
Your answer
Follow this Question
Related Questions
c# parsing error Help please and the error is at where it says public string Name 1 Answer
CS8025 parsing error 1 Answer
CS8025 Parsing error 3 Answers
Parsing Error 2 Answers
Assets/Scripts/PlayerController.cs(22,25): error CS8025: Parsing error 0 Answers