27 lines
594 B
C#
27 lines
594 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Movement : MonoBehaviour
|
|
{
|
|
public float moveSpeed = 5f;
|
|
private Vector3 direction;
|
|
public Rigidbody rb;
|
|
private float horizontal, vertical;
|
|
|
|
private void Awake() {
|
|
rb = GetComponent<Rigidbody>();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
horizontal = Input.GetAxis("Horizontal");
|
|
vertical = Input.GetAxis("Vertical");
|
|
|
|
direction = new Vector3(horizontal, 0,vertical);
|
|
|
|
rb.AddForce(direction * moveSpeed);
|
|
}
|
|
}
|