- Home /
Question is off-topic or not relevant
Why wont my follow scripts work?
Im trying to create an atmospheric maze game, and I want the monster ive created to follow me, so Ive been looking online for one. ive tried about 70 different scripts now, but none of them have worked. can you help me?
This morning, I made eggs but they did not fry the way I wanted them. I look online and try again many other ways but still, it is not what I want. Can you tell me why?
Can you post what you have so far and explain what is not working?
If you would post one of the scripts and also explain the question in detail, then I think it would be easier to help you.
Answer by $$anonymous$$ · Aug 17, 2013 at 02:54 PM
Attach this to monster,set player(you),and set speed. But unity answers isnt for asking scripts,but to help find out problem.
using UnityEngine;
using System.Collections;
public class FollowScript : MonoBehaviour {
public Transform playerToFollow; // Set player you want to follow on the scene
public float speed = 50f; //speed
void Update()
{
if(playerToFollow !=null)
{
transform.position = Vector3.MoveTowards(transform.position,player.transfrom.position,speed * Time.deltaTime);
}
else
{
Debug.Log("Player is not set");
}
}
}