Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Parser Error Unexpected symbol `private'

$
0
0
When I first made my script it worked just fine. Today I came back and it wouldn't let me add the script to anything because of the private error. Here is my entire code and I don't know why it isn't working. Can someone please tell me why it isn't working? using UnityEngine; using System.Collections; public class PlayerAttack : MonoBehaviour { public GameObject target; public float attackTimer; public float coolDown; // Use this for initialization void Start () { attackTimer = 0; coolDown = 0.5f; } // Update is called once per frame void Update () { if (attackTimer > 0) attackTimer -= Time.deltaTime; if (attackTimer < 0) attackTimer = 0; if (Input.GetKeyUp (KeyCode.F)) { if(attackTimer == 0){ Attack(); attackTimer = coolDown; } } private void Attack(){ //<---- This is where the error is 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(distance); if(distance < 3) { if(direction > 0) { EnemyHealth eh = (EnemyHealth)target.GetComponent ("EnemyHealth"); eh.AddjustCurrentHealth (-10); } } } }

Viewing all articles
Browse latest Browse all 7934

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>