- Home /
Help with script from Unity BurgZergArcade Tutorial 6
I am following Burg Zerg Arcade tutorials, I am working on tutorial number 6. The following line has an error. float direction = Vector3.Dot(dir, transform.forward); The error is error CS1525: Unexpected symbol 'float'
Any suggestions?
Seems fine based on what you have posted. Could you post more of the surrounding code?
Here is rest of script:
using UnityEngine; using System.Collections;
public class PlayerAttack : $$anonymous$$onoBehaviour { public GameObject target;
// Use this for initialization void Start () {
}
// Update is called once per frame void Update () { if(attackTimer > 0) attackTimer -= Time.deltaTime;
if(attackTimer < 0) attackTimer = 0;
if(Input.Get$$anonymous$$eyUp($$anonymous$$eyCode.F)) {
} }
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);
Debug.Log(direction);
if(distance < 2.5f) { if(direction > 0) { EnemyHealth eh = (EnemyHealth)target.GetComponent("EnemyHealth"); eh.AddjustCurrentHealth(-5); } } } }
Answer by RaysFan · Jul 19, 2012 at 11:43 PM
Here is code: using UnityEngine; using System.Collections;
public class PlayerAttack : MonoBehaviour { public GameObject target;
// Use this for initialization void Start () {
}
// Update is called once per frame void Update () { if(attackTimer > 0) attackTimer -= Time.deltaTime;
if(attackTimer < 0) attackTimer = 0;
if(Input.GetKeyUp(KeyCode.F)) {
} }
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);
Debug.Log(direction);
if(distance < 2.5f) { if(direction > 0) { EnemyHealth eh = (EnemyHealth)target.GetComponent("EnemyHealth"); eh.AddjustCurrentHealth(-5); } } } }
Answer by Doireth · Jul 19, 2012 at 11:23 PM
The line:
Vector3 dir = (target.transform.position - transform.position).normalized
Just before the:
float direction = Vector3.Dot(dir, transform.forward);
Is missing a semi-colon (;) at the end of the line. Simple syntax error. The error saying the "unexpected symbol float" means that it expected something other than "float", in this case it's the semi-colon.
Parser errors.....I have a feeling I will have to rewrite script. :(
Your answer

Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Vehicle Script Debugging 1 Answer
Need a bit of help with my script (about 100 lines) 1 Answer
How to make the trigger work only once. (SOUND) 1 Answer
Score System help 1 Answer