Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class PlayerMovementTest1 : MonoBehaviour {
- public float speed;
- public float rotationSpeed;
- Vector3 rotation;
- Rigidbody rb;
- float horizontal;
- float vertical;
- // Use this for initialization
- void Start () {
- rb = GetComponent<Rigidbody>();
- }
- // Update is called once per frame
- void Update () {
- rotation = new Vector3(0f, Input.GetAxis("Horizontal2"), 0f);
- horizontal = Input.GetAxis("Horizontal");
- vertical = Input.GetAxis("Vertical");
- }
- void FixedUpdate()
- {
- rb.MoveRotation(transform.rotation * Quaternion.Euler(rotation * rotationSpeed));
- rb.MovePosition(rb.position + (transform.forward * vertical) * speed);
- rb.MovePosition(rb.position + (transform.right * horizontal) * speed);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement