Advertisement
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
- {
- Rigidbody rb;
- public float speed;
- // Start is called before the first frame update
- void Start()
- {
- rb = GetComponent<Rigidbody>();
- }
- // Update is called once per frame
- void Update()
- {
- float h = Input.GetAxisRaw("Horizontal");
- float v = Input.GetAxisRaw("Vertical");
- Vector3 dir = new Vector3(h, 0, v);
- rb.AddForce(dir * Time.deltaTime * speed);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement