Newer
Older
Dreamsturbia-Project-IADE-Unity3D / Assets / Scripts / CharMovementPhy.cs
@Rackday Rackday on 21 Aug 666 bytes Project Added
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CharMovementPhy : MonoBehaviour
{
    private float horizontalInput;
    private float verticalInput;

    [SerializeField]
    private float velocity;

    private Rigidbody rb;
    void Start()
    {
        rb = GetComponent<Rigidbody>();
    }

    // Update is called once per frame
    void Update()
    {
        horizontalInput = Input.GetAxis("Horizontal");
        verticalInput = Input.GetAxis("Vertical");
    }
    private void FixedUpdate()
    {
        rb.velocity = new Vector3(verticalInput * velocity, rb.velocity.y, horizontalInput * velocity);
    }
}