using System.Collections; using System.Collections.Generic; using UnityEngine; using PathCreation; //<---- Don't forget public class PlayerMovePath : MonoBehaviour { //Variables [SerializeField] private PathCreator _pathCreator; [SerializeField] private float _speed = 5.0f; private float _distanceTravelled; // Update is called once per frame void Update() { _distanceTravelled += _speed * Time.deltaTime; transform.position = _pathCreator.path.GetPointAtDistance(_distanceTravelled); transform.rotation = _pathCreator.path.GetRotationAtDistance(_distanceTravelled); } //This may also work, not proven yet void FixedUpdate() { _distanceTravelled += _speed * Time.fixedDeltaTime; _rb.MovePosition(_pathCreator.path.GetPointAtDistance(_distanceTravelled)); _rb.MoveRotation(_pathCreator.path.GetRotationAtDistance(_distanceTravelled)); } }