Quantcast
Channel: Latest Questions by ryno9788
Viewing all articles
Browse latest Browse all 91

super messed up speed

$
0
0
I have been working on this new script for my new controller for my fps Game. Right now I believe it will technically how I want it but its now working very fast, too fast! The problem begins with the basic movement forwards and backwards I wanted to make the controller to be able to still have a little control while falling. Well I had some problems with collision (any object that I walked into I would just go through other than the ground) so I had to change the way my player moves. This is were my problems started. I fixed the collision problem but now my player is moving super fast (I've turned down the speed but I'd like it fixed before future issues) the gravity is having the same issue but the worst part is the jumping. No matter how low I turn it down it will either not go that far or transport above in about 1 or 2 frames. Can someone please find and fix these errors? using UnityEngine; using System.Collections; public class basicmove : MonoBehaviour { public bool NotClimbing = true; public bool HasJumped = false; public float speed = 10.0F; public float sidestepSpeed = 6.0F; public float gravity = 12.0F; public float jumpSpeed = 8.0F; public Vector3 Wall = Vector3.zero; // this variable used to meen somthing else but I've neglected to change the name //it does seem unessisary private Vector3 moveDirection = Vector3.zero; void Update() { CharacterController controller = GetComponent(); moveDirection.y -= gravity * Time.deltaTime;// applying gravity controller.Move(moveDirection); if (controller.isGrounded) { if(NotClimbing){//you are walking ////////moving axis///////// moveDirection = new Vector3 (Input.GetAxis("Horizontal")* sidestepSpeed, 0, Input.GetAxis("Vertical")* speed); moveDirection = transform.TransformDirection(moveDirection); if (Input.GetButtonDown("Jump")) { HasJumped = true; } } ////////moving axis///////// else //you are on the ground facing a wall { moveDirection = new Vector3 (Input.GetAxis("Horizontal")* sidestepSpeed, Input.GetAxis("Vertical")* speed,0); moveDirection = transform.TransformDirection(moveDirection); } } else{ ////////moving axis///////// HasJumped = false; if(NotClimbing){ moveDirection = new Vector3 (Input.GetAxis("Horizontal")*(sidestepSpeed*2), 0, Input.GetAxis("Vertical")* ((speed/2)-(speed/4))); moveDirection = transform.TransformDirection(moveDirection); } else { ////////moving axis///////// moveDirection = new Vector3 (Input.GetAxis("Horizontal")* sidestepSpeed, Input.GetAxis("Vertical")* speed,0); moveDirection = transform.TransformDirection(moveDirection); } } } void LateUpdate() { if(HasJumped){ if (NotClimbing){ moveDirection.y = jumpSpeed;}// jump movement else{ moveDirection.z = (jumpSpeed * -1); //jump movement when climbing } } } }

Viewing all articles
Browse latest Browse all 91

Latest Images

Trending Articles





Latest Images