Hi!
Hi
I need to find the transform of a gameobject. I have this code:
using UnityEngine;
using System.Collections;
public class ZombieMovement : MonoBehaviour {
private Transform playerPos;
public float moveSpeed;
void Start () {
playerPos = GameObject.Find ("Swordsman(clone)").transform.position;
}
void Update () {
float move = moveSpeed * Time.deltaTime;
transform.position = Vector3.MoveTowards (transform.position, playerPos.position, move);
}
}
But i keep getting the error: “Cannot implicitly convert type UnityEngine.Vector3' to
UnityEngine.Transform’” What should i do if i wanted do get the position of Player(clone) and use it in
float move = moveSpeed * Time.deltaTime;
transform.position = Vector3.MoveTowards (transform.position, playerPos.position, move);
?
Thanks in advance!