OtroIntentoDe

ControlJugador

Sep 17th, 2017
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class ControlJugador : MonoBehaviour {
  6.  
  7.     private Rigidbody rb;
  8.     public float velocidad;
  9.     public GameObject referencia;
  10.  
  11.     void Start () {
  12.         rb = GetComponent<Rigidbody> ();
  13.     }
  14.  
  15.     void FixedUpdate () {
  16.         float horizontal = Input.GetAxis ("Horizontal");
  17.         float vertical = Input.GetAxis ("Vertical");
  18.  
  19.         rb.AddForce (vertical * referencia.transform.forward * velocidad);
  20.         rb.AddForce (horizontal * referencia.transform.right * velocidad);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment