Basic movement


First operational deplacement made for our players.

We began like that.


After corrections, we achieved:


Now, the next challenge is synchronize animations with deplacement smoothly.



The code of the script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Test_Deplacem2 : MonoBehaviour
{
    public float _Fl_Speed;//, _Fl_Gravity, _Fl_Max_Vel_Change;
    private Transform _Trans_Player;
    private Rigidbody _RB_Player;
    public Transform _Trans_LookAt;
    // Start is called before the first frame update
    void Start()
    {
        _Trans_Player = GetComponent<Transform>();
        _RB_Player = GetComponent<Rigidbody>();

    }

    // Update is called once per frame
    void FixedUpdate()
    {
        LookAt();
        MoveTo();
    }

    void LookAt()
    {
        Vector3 _V3_Look=new Vector3(-Input.GetAxis("Vertical"), 0, Input.GetAxis("Horizontal"));
        _Trans_Player.LookAt(_Trans_LookAt.position+_V3_Look);
    }
    void MoveTo()
    {
         Vector3 _V3_MovVelocity = new Vector3(-Input.GetAxis("Vertical"), 0, Input.GetAxis("Horizontal"))*_Fl_Speed;
        //_V3_MovVelocity = _Trans_Player.TransformDirection(_V3_MovVelocity);
        _V3_MovVelocity *= 10;
        _RB_Player.AddForce(_V3_MovVelocity);
    }
}

Also we share the RigidBody config:


Leave a comment

Log in with itch.io to leave a comment.