- Home /
please i beg of you help!!!!!!!!!!!!!!!
ok i am a noob i never done scripting but i have been following the tornadotwins i am doing the worm game tut....i am at the part when you make the movment for the worm ..... this is where i had to add a character controller to it beofroe scripting but here is the script thay gave me to add to the worm
var speed = 6.0;
var rotateSpeed = 3.0;
function Update()
{
var controller : CharacterController = GetComponent(CharacterController);
//Rotate on Y
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
//Move forward/back
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis ("Vertical");
controller.SimpleMove(forward * curSpeed);
}
@script RequireComponent(CharacterController)
ok now every thing works but the jumping part i know there is no jumping action in this script but in the tuts thay made the worm jump can someone please just tell me what to add and make shure it works please i just want to make it jump i need it to jump up in the air when i press space like a normal game if you please answer for me and i did go back and i checked if i missed any thing in the videos i did not
Any chance you could edit the title of this question to be in line with the FAQ? This is a knowledge base and the title of the question should be something someone else might one day search for.
um how lol i am a noob rember please give me the insruction on how to add this to the location you are refuring to
nver$$anonymous$$d i went into the forms and made a thread about it
Answer by Ingen · Jul 21, 2012 at 09:11 PM
Hallo! I think this can help you
http://answers.unity3d.com/questions/12911/what-are-the-syntax-differences-in-c-and-javascrip.html
and over all
http://forum.unity3d.com/threads/113937-Getting-Started-with-Coding-for-Unity
http://www.unifycommunity.com/wiki/index.php?title=Tutorials
regards
Answer by Dee Va · Jul 21, 2012 at 02:16 AM
var jumpSpeed: float = 5.0;
var speed: float = 6.0;
var rotateSpeed: float = 60.0;
var gravity: float = 10.0; // gravity acceleration
private var vSpeed: float = 0; // store vertical speed in a separate variable
function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);
// Rotate around y - axis
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed * Time.deltaTime, 0);
// Move forward / backward
var curSpeed = speed * Input.GetAxis ("Vertical");
var moveDir = transform.forward * curSpeed;
// Jump code
if (controller.isGrounded){ // if character is grounded...
vSpeed = 0; // its vert speed is zero
if (Input.GetButtonDown("Jump"))
{ // but if jump pressed, set it to jumpSpeed
vSpeed = jumpSpeed;
}
}
// apply gravity acceleration
vSpeed -= gravity * Time.deltaTime;
moveDir.y = vSpeed; // include vSpeed in moveDir
// moveDir * Time.deltaTime is the displacement since last frame
controller.Move(moveDir * Time.deltaTime);
}
um i like the idea of it but when i jump its like a teleport lol is that onpurpose of what lol i need a jump not a teleport in the air
What teleport?? you mean your player Staying long time in air? is that so decrease the Jump speed or increase the Gravity... Hope it Helped :D
i mean when i press the jump button insted of a jump its like a super quick teleport in the air depending on the jump speed on like 10 he dissapres off the screen and falls down slow on 1 he just dose a super quick hop just try to inmagin like a super jump up its like it skips frames going up so you never can see a smooth jump just a smooth down lol
never $$anonymous$$d dude thanks i fixed it with the gravity thank you thank you!!!!!!!!!!!!! ok i relly want to learn how you learnd to scrpit like that i mean how long did it take i just want to be able to creat basic scripts like this one we are talking about i kinda understand it becuse i just keep looking at the script but do you have any suggetstions any website you went to any thing i want to get into this stuff and i do know how to spell its just when i type fast i miss some letters and stuff cuz i am about to go out lol so if you answer i will get back to you soon thank you dude ..
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Targetting error please help 0 Answers
Increase Jump Through Mouse Clicks? 1 Answer
A node in a childnode? 1 Answer
Need help with my script. 2 Answers