Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Player : MonoBehaviour {
- public Rigidbody rid;
- public Vector3 direction;
- public float speed = 100f;
- // Use this for initialization
- void Start () {
- rid = GetComponent<Rigidbody>();
- }
- void Update () {
- float h = Input.GetAxis("Horizontal");
- float v = Input.GetAxis("Vertical");
- direction.x = h;
- direction.z = v;
- rid.AddForce(direction.normalized*speed*Time.deltaTime);
- }
- }
Add Comment
Please, Sign In to add comment