Question by
SSEthanCray · Jan 08, 2018 at 02:05 AM ·
c#positionvector3unity 2dmovetowards
Vector3.MoveTowards Problems
I'm not sure what I'm doing wrong.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EctoSplash : MonoBehaviour {
public void FixedUpdate (Vector3 target) {
ShootTowards(target);
}
void ShootTowards (Vector3 target) {
transform.position = Vector3.MoveTowards(transform.position, target, 5 * Time.deltaTime);
}
}
The Vector3 "target" is set in another script. I setup a Debug.Log, which had target in it. The console gave me my desired position, but the Vector3.MoveTowards is just not working. Also, when I make my functions not require any parameters, and set the target to 0,0,0 it works fine. So, I know the problem must lie within there. This is all in 2D btw. Can I get some help?
Comment