Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class FPS : MonoBehaviour {
- public float speedH = 2.0f;
- public float speedV = 2.0f;
- public Rigidbody m_Rigidbody;
- private float yaw = 0.0f;
- private float pitch = 0.0f;
- public float m_Speed = 5f;
- public void Start(){
- m_Rigidbody = this.GetComponent<Rigidbody>();
- }
- void Update () {
- yaw += speedH * Input.GetAxis("Mouse X");
- pitch -= speedV * Input.GetAxis("Mouse Y");
- transform.eulerAngles = new Vector3(pitch, yaw, 0.0f);
- if (Input.GetAxis("Vertical") != 0){
- m_Rigidbody.velocity = transform.forward * m_Speed * Input.GetAxis("Vertical");
- }
- if (Input.GetAxis("Horizontal") != 0){
- m_Rigidbody.velocity = transform.right * m_Speed * Input.GetAxis("Horizontal");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement