Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class testmovement : MonoBehaviour {
- public float speed = 6.0F;
- public float jumpSpeed = 8.0F;
- public float gravity = 20.0F;
- private Vector3 moveDirection = Vector3.zero;
- void Update() {
- CharacterController controller = GetComponent<CharacterController>();
- if (controller.isGrounded) {
- transform.forward * Input.GetAxis("Vertical") * speed;
- moveDirection = new Vector3( 0, 0, 0);
- moveDirection = transform.TransformDirection(moveDirection);
- moveDirection *= speed;
- if (Input.GetButton("snopp"))
- moveDirection.y = jumpSpeed;
- }
- moveDirection.y -= gravity * Time.deltaTime;
- controller.Move(moveDirection * Time.deltaTime);
- }
- }
Add Comment
Please, Sign In to add comment