I have a simple normalized movement script ,but how could I add jumping? Is there a better way to do this so that I can have running speeds and such? I want to have a script like the FPSWalkerEnhanced script ,but that has normalized movement. Any help would be great! Thanks!
Here’s the script:
using UnityEngine;
using System.Collections;
//
//THIS SCRIPT CONTROLS THE MOVEMENT OF THE PLAYER
//
public class PlayerMovement : MonoBehaviour
{
//ALL OF THE PUBLIC VARIABLES
public float walkSpeed = 6.0f;
public float runSpeed = 12.0f;
//ALL OF THE PRIVATE VARIABLES
private Vector3 moveDirection;
private float speed;
void Start ()
{
speed = walkSpeed;
}
void Update ()
{
moveDirection = new Vector3 (Input.GetAxisRaw ("Horizontal"),0, Input.GetAxisRaw ("Vertical")).normalized;
}
void FixedUpdate()
{
rigidbody.MovePosition (rigidbody.position + transform.TransformDirection(moveDirection) * speed * Time.deltaTime);
}
}