Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

character wont Jump :(

$
0
0
okay so i've made some progress on my game but now i'm trying to get my character to Jump (with its own custom jump animation) but it does nothing, it walks and does all the other actions i've scripted so far but it wont jump :( #pragma strict var rotationSpeed : float = 10; var walkSpeed : float = 7; var gravity : float = 50; private var yRot : float; var body : Transform; var jumpSpeed = 8.0; function Update () { var Controller : CharacterController = GetComponent(CharacterController); var vertical : Vector3 = transform.TransformDirection(Vector3.forward); var horizontal : Vector3 = transform.TransformDirection(Vector3.right); var height : Vector3 = transform.TransformDirection(Vector3.up); if (Input.GetButtonDown ("Jump")){ animation.CrossFade ("Jump"); } if(Input.GetAxis("Vertical") || Input.GetAxis("Horizontal")){ animation.CrossFade("walk", 0.2); animation["walk"].speed = walkSpeed/10; Controller.Move((vertical *(walkSpeed* Input.GetAxis("Vertical"))) *Time.deltaTime); Controller.Move((horizontal *(walkSpeed* Input.GetAxis("Horizontal"))) *Time.deltaTime); }else{ animation.CrossFade("idle", 0.2); } if(Input.GetAxis("Mouse X")){ yRot += 10 * Input.GetAxis("Mouse X"); } Controller.Move(height *-gravity* Time.deltaTime); } function LateUpdate(){ if(Input.GetAxis("Vertical") == 0){ if(Input.GetAxis("Horizontal") > 0){ body.localEulerAngles.y = 90; }else if(Input.GetAxis("Horizontal") < 0){ body.localEulerAngles.y = -90; } }else if(Input.GetAxis("Vertical") > 0){ if(Input.GetAxis("Horizontal") > 0){ }else if(Input.GetAxis("Horizontal") < 0){ } }else if(Input.GetAxis("Vertical") < 0){ if(Input.GetAxis("Horizontal") > 0){ }else if(Input.GetAxis("Horizontal") < 0){ } } i've looked through forums, youtube and google for ages and haven't found an answer >.< if anyone can tell me where i've gone wrong in my script it would really help! x

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>