Newmap9
February 11, 2013, 10:37am
1
Hello everyone yesterday i try to using a java script to make my units available to shoot however i got an error message it say:
Can’t add script behaviour Player_fire. You need to fix all compile errors in all script first!!
So i cannot use this script below is there any problem?
#pragma strict
var fireballbullet | Transform/
function Start () {
}
function Update () {
}
If (Input.GetKeyUp("e"))
{
var bulletfire = Instantiate {fireballbullet,gameObject.Find("bullet_SpawnPoint").transform.position,Quaternion.identity)
bulletfire.rigidbody.Addforce{Transform.forward * 500};
}
}
Addforce(Transform.forward * 500)
I believe AddForce should use normal brackets not curly brackets but I’m a C# programmer. Best of luck. Also not sure on “var fireballbullet | Transform/” I think “var fireballbullet | Transform;” or “var fireballbullet : Transform;” is correct. But as I’ve said I’m a C# programmer. Best of luck.
If you double click error message it should take you to the line with the error in mono develop.
I think the error is the wrong bracket after addforce …
Newmap9
February 12, 2013, 11:19am
4
Thank you for your reply today i refit the script like:
#pragma strict
var fireballbullet : Transform;
function Start () {
}
function Update ()
{
If (Input.GetKeyUp(“e”))
{
var bulletfire = Instantiate (fireballbullet,gameObject.Find(“bullet_SpawnPoint”).transform.position,Quaternion.identity)
bulletfire.rigidbody.Addforce(transform.forward. * 500);
}
}
But it have an error and it say:
Assets/Scripts/Player_Fire.js(12,130):UCE0001: ‘;’ expected. Insert a semicolon at the end.
Any idea what this mean???