I’ve been trying to do this for a while, all the information I can find doesn’t help, maybe I’m looking in the wrong place.
I have the player and in the menu there are buttons with different places. What I wanted to do is when the player clicks in one of the buttons a trail appears that leads the player there.
Any help?
If you want to move the player from one point to another there are a few different ways of going about it but the best would be to use Vector3.lerp
public Transform startMarker;
public Transform endMarker;
public float speed = 1.0F;
private float startTime;
private float journeyLength;
void Start() {
startTime = Time.time;
journeyLength = Vector3.Distance(startMarker.position, endMarker.position);
}
void Update() {
float distCovered = (Time.time - startTime) * speed;
float fracJourney = distCovered / journeyLength;
transform.position = Vector3.Lerp(startMarker.position, endMarker.position, fracJourney);
}
Attach this code into a script on your object and give it the starting and ending positions, you can also add a ‘trail renderer’ component to show a trail on the object.