- Home /
skigame movement problem
hello. i am working on a ski game but i got a little smoothness problem whit my movementscript please jump over a few hills and see it yourself:click here
as you could see: if you make a big jump its shaking your whole character
PS: this is not the game it self just a little scene i made for my question
this is the script:
var speed : float = 10.0;
var jumpSpeed : float = 8.0;
var gravity : float = 10.0;
private var moveDirection : Vector3 = Vector3.zero;
var tracker: Transform;
var rotateSpeed = 3.0;
function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis ("Vertical");
controller.SimpleMove(forward * curSpeed);
var hit1: RaycastHit;
var hit2: RaycastHit;
if (Physics.Raycast(tracker.position, -Vector3.up, hit1)) {
if (Physics.Raycast(tracker.TransformPoint(Vector3.forward * 0.1), -Vector3.up, hit2)) {
transform.rotation = Quaternion.LookRotation(hit2.point - hit1.point, hit1.normal);
}
if (controller.isGrounded) {
moveDirection = Vector3(Input.GetAxis("Horizontal"), 0,
Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
if (Input.GetButton ("Jump")) {
moveDirection.y = jumpSpeed;
}
}
controller.Move(moveDirection * Time.deltaTime);
}
}
function FixedUpdate () {
rigidbody.AddForce (-Vector3.up * 10);
}
@script RequireComponent(CharacterController)
please. can someone fix this problem?
Comment
Your answer
Follow this Question
Related Questions
How to make smooth jump? 1 Answer
How to move smoothly without using iTween? 1 Answer
Smooth Camera Follow Script, Weird Movement... Please help! 1 Answer
Trying to Add jump to this code. 1 Answer
Movement Script 1 Answer