Last active
June 4, 2019 08:32
-
-
Save aviralgoel/132cd87b44cbbb02e5cd7d558f7f12a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class PlayerMovement : MonoBehaviour | |
{ | |
public float speed; | |
private Rigidbody rb; | |
void Start() | |
{ | |
rb = GetComponent<Rigidbody>(); | |
} | |
void FixedUpdate() | |
{ | |
float moveHorizontal = Input.GetAxis("Horizontal"); | |
float moveVertical = Input.GetAxis("Vertical"); | |
Vector3 movement = new Vector3(moveHorizontal, 0, moveVertical); | |
rb.AddForce(movement * speed); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment