Hello I have some problems with a script the error will be underlined the error message in the debug modus is Identifier Missing Code (csharp): using UnityEngine; using System.Collections; public class trees : MonoBehaviour { public int chopDistence = 10; public int chopTime = 5; public bool inRange = false; public Transform playere; void Update() { float ; Vector3 player = playere.transform.position; float ; Vector3 moveDirection = player - transform.position; if (moveDirection <= chopDistence) { inRange = true; } else if (moveDirection >= chopDistence) { inRange = false; } if (inRange == true) { if(Input.GetMouseButtonUp(0)) { StartCoroutine (Timer (chopTime)); } } } IEnumerator Timer(float seconds) { yield return new WaitForSeconds(seconds); Destroy(gameObject); print ("Player_Inventory.players_wood"); } }
few issues i can see here: first off: [code ] [/code ] tags when you paste in code to the forums please. Helps with formatting and makes it a lot more readable. secondly: playere is a transform, so asking for it's transform is a little redundant. Keep an eye on your data types. thirdly: if the variable "player" is the position from playere why isn't it called "playerPosition"? far more readable, would allow the public variable to be called "player" instead of the slightly odd "playere" (unless that's a language translation thing?). Keep your variables, functions and names in general as readable and specific as possible. When your code gets big, or when you open an old project to borrow some functionality you'll be thankful of things being what they say they are. lastly (and the actual issue the error is refering to): what is this Code (csharp): float ; Vector3 player ... float ; Vector3 moveDirection ... is it a float? or a Vector3? is this unityscript (except they're semicolons and not colons) or c#? it's all mixed up. I think you wanted Code (csharp): Vector3 playerPosition = player.position;
Code (CSharp): using UnityEngine; using System.Collections; public class trees : MonoBehaviour { public int chopDistence = 10; public int chopTime = 5; public bool inRange = false; public Transform playerT; void Update() { Vector3 player = playerT.position; Vector3 moveDirection = player - transform.position; if (moveDirection.magnitude <= chopDistence) { if(Input.GetMouseButtonUp(0)) { StartCoroutine (Timer (chopTime)); } } } IEnumerator Timer(float seconds) { yield return new WaitForSeconds(seconds); Destroy(gameObject); print ("Player_Inventory.players_wood"); } } If your code is C# this version raises no errors.