- Home /
Tornado Twins level 5 fireball
I followed the coding exactly and it still will not work. Please help.
var speed = 10.0; var rotateSpeed = 3.0; var bullitPrefab:Transform;
function Update () { var controller : CharacterController = GetComponent(CharacterController); //Rotate around y - axis transform.Rotate(0,Input.GetAxis ("Horizontal") * rotateSpeed, 0);
//Move forward/backward var forward: Vector3 = transform.TransformDirection(Vector3.forward); var curSpeed : float = speed*Input.GetAxis("Vertical"); controller.SimpleMove(forward*curSpeed);
if(Input.GetButtonDown("Jump")); { var bullit = Instantiate(bullitprefab,transform.find("SpawnPoint").transform.position ,Quaternion.identity); }
}
@script RequireComponent (CharacterController)
One word about the Tornado Twins' tutorials, I have been through 2 of their tutorials including one that they actually sell. If they are good for starting (the tutorials) they are also dangerous as some of their codes miraculously work on the video but when you try them on your project they go weird or return unexpected values. Also, they often get satisfied of their work clai$$anonymous$$g "That works nicely!!" while you clearly see something wrong. To be used carefully.
Answer by DavidDebnar · Feb 11, 2012 at 11:31 AM
Here is the modified code, it should work properly, just make sure that you have a fireball prefab dragged onto the bullitPrefab variable and that you have a empty gameObject called SpawnPointer parented to the player/worm. And make sure that you use GameObject.Find instead of transform.find, or make a variable
var spawn : Transform;
and use it as
var bullit = Instantiate(bullitprefab, spawn.transform.position, Quaternion.identity);
In te if statement at the end and it should work.
var speed = 10.0;
var rotateSpeed = 3.0;
var bullitPrefab : Transform;
var controller : CharacterController;
function Start () {
controller = GetComponent(CharacterController);
}
function Update () {
transform.Rotate(0,Input.GetAxis ("Horizontal") * rotateSpeed, 0);
var forward: Vector3 = transform.TransformDirection(Vector3.forward);
var curSpeed : float = speed*Input.GetAxis("Vertical");
controller.SimpleMove(forward*curSpeed);
if(Input.GetButtonDown("Jump"))
{
var bullit = Instantiate(bullitprefab, GameObject.Find("SpawnPoint").transform.position, Quaternion.identity);
}
}
@script RequireComponent (CharacterController)
David
It still wont work. the errors are
unexpected token:var and ';' expected. Insert a semicolon at the end.
Which line? There was an error at the end of the if statement.
Your answer
Follow this Question
Related Questions
please help me!!!!!!!!!!!!!!!!!!!! 2 Answers
How to convert joystick position to rotation? 0 Answers
How to make network player lose health after being hit by rigidbody? 1 Answer
Roll-A-Ball tutorial help. 0 Answers
Create Fireball with fire effect 1 Answer