Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PlayerController : MonoBehaviour
- {
- public float moveSpeed = 5f;
- Vector3 startingPos;
- Vector3 currentPos;
- Vector3 targetPos;
- private void Start()
- {
- startingPos = new Vector3(0, 1.1f, 0);
- currentPos = startingPos;
- targetPos = startingPos;
- }
- private void FixedUpdate()
- {
- if (targetPos != currentPos)
- {
- Debug.Log($"Moving from {currentPos} to {targetPos}");
- transform.position = Vector3.MoveTowards(currentPos, targetPos, moveSpeed * Time.fixedDeltaTime);
- currentPos = transform.position;
- }
- }
- public void SetNewDest(Vector3 target)
- {
- targetPos = target;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement