So I want my character to move forward a set distance with a button press (this will be switched to a key press but I can manage that code switch) but right now, the character just kinda teleports instead of it being a smooth glide. I wasn’t sure if I needed to add Time.deltaTime for the smooth transition or not so this is what I have so far:
UPDATE 11/16: So I changed the formatting of the code to use Vector3.Lerp but I’m still not getting a smooth movement for some reason. I even tried to adjust the speed and nothing has really worked out yet.
using UnityEngine;
using System.Collections;
public class BattleMovement : MonoBehaviour {
public Transform targetPos;
public void MoveSquare () {
var obj = GameObject.Find ("GameObject");
targetPos = obj.transform;
targetPos.transform.Translate (0, 0, 100);
obj.transform.position = Vector3.Lerp(obj.transform.position,
targetPos.position, Time.deltaTime * 2);
}
}