Untitled
unknown
plain_text
7 months ago
583 B
9
Indexable
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerController : MonoBehaviour
{
[SerializeField] private Rigidbody rbody;
[SerializeField] private float speed = 5;
private Vector3 input;
void Update(){
GatherInput();
}
void FixedUpdate() {
Move();
}
void GatherInput() {
input = new Vector3(Input.GetAxisRaw("Horizontal"),0, Input.GetAxisRaw("Vertical"));
}
void Move() {
rbody.MovePosition(transform.position + input * speed * Time.fixedDeltaTime);
}
}
Editor is loading...
Leave a Comment