- Home /
';' expected. Insert a semicolon at the end. already one there?
Im trying to target something using js
PlayerAttack script is CS could that be the problem?
public var target : Transform; function Update() { //check if the left mouse has been pressed down this frame if (Input.GetMouseButtonUp(0)) { //empty RaycastHit object which raycast puts the hit details into var hit : RaycastHit; //ray shooting out of the camera from where the mouse is var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, hit)) { if (hit.collider.gameObject.CompareTag("Enemy")){ //print out the name if the raycast hits something Debug.Log(hit.collider.name); target = hit.collider.transform; PlayerAttack pa = (PlayerAttack)GetComponent("PlayerAttack"); pa.target = target.gameObject; } else { Debug.Log(hit.collider.name + " no tag"); } }
}
}
PlayerAttack pa = (PlayerAttack)GetComponent("PlayerAttack");
Assets/NewBehaviourScript.js(17,23): UCE0001: ';' expected. Insert a semicolon at the end.
Assets/NewBehaviourScript.js(17,43): UCE0001: ';' expected. Insert a semicolon at the end.
Answer by DaveA · Apr 05, 2011 at 12:54 AM
That's C#. Try this:
var pa : PlayerAttack = GetComponent("PlayerAttack");
Well, he mixed JS and C#. One of the first things i checked ;)
Yeah, that won't work. You know, just because the component you're getting is C# doesn't mean C# syntax will work in the JS you're getting it into!
The only parts of that script that I took from a cs script is PlayerAttack pa = (PlayerAttack)GetComponent("PlayerAttack"); pa.target = target.gameObject;
im trying to make the Target i've clicked on the target in the playerattack script.
Assets/Standard Assets/ScriptsDB/Targetting/targetjs.js(20,26): BCE0018: The name 'PlayerAttack' does not denote a valid type ('not found').
Should I be putting the scripts in the same folder?
Your answer
Follow this Question
Related Questions
Scripting error: ';' expected. Insert a semicolon at the end. 2 Answers
doing force and spin on a gameobject when clicking on plane. 2 Answers
UCE0001: ';' expected. Insert a semicolon at the end. 2 Answers
Using JavaScript and C# inside one script 2 Answers
help with UCE0001: ';' expected. Insert a semicolon at the end 3 Answers