Vector2.MoveTowards Not Working
The game object does not move when spawned... Here is the code:
using UnityEngine;
using System.Collections;
public class MoveTrail : MonoBehaviour {
public int moveSpeed = 230;
public string PlayerTag = "Player";
private Vector2 PlayerPos;
void Start()
{
GameObject Target = GameObject.FindWithTag(PlayerTag);
PlayerPos = new Vector2(Target.transform.position.x, Target.transform.position.y);
Debug.Log(PlayerPos);
}
// Update is called once per frame
void Update() {
Vector3.MoveTowards(this.transform.position , PlayerPos, moveSpeed * Time.deltaTime);
}
}
Comment
Best Answer
Answer by pranesh-arry · May 08, 2018 at 05:00 PM
Okay So I figured out the issue by myself, all I needed to do was
this.transform.position = Vector3.Movetowards(yadayadayada);
Rookie Mistake, I just needed to assign the position of the object! My bad