Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.56 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Player : MonoBehaviour
  6. {
  7.     Rigidbody rb;
  8.     public float speed;
  9.  
  10.     // Start is called before the first frame update
  11.     void Start()
  12.     {
  13.         rb = GetComponent<Rigidbody>();
  14.     }
  15.  
  16.     // Update is called once per frame
  17.     void Update()
  18.     {
  19.         float h = Input.GetAxisRaw("Horizontal");
  20.         float v = Input.GetAxisRaw("Vertical");
  21.  
  22.         Vector3 dir = new Vector3(h, 0, v);
  23.  
  24.         rb.AddForce(dir * Time.deltaTime * speed);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement