Hello, i’m trying to create a script (C#) where the transform follows a target, the current script is:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Follow : MonoBehaviour {
Transform target;
int moveSpeed = 3;
int rotationSpeed = 3;
Transform myTransform;
void Awake(){
myTransform = transform;
}
// Use this for initialization
void Start () {
target = GameObject.FindWithTag ("Player").transform;
}
// Update is called once per frame
void Update () {
myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime); myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
}
}
It works just fine for following, but it follow backwards, he is walking backwards to the character, i’ve tried to change the Y rotation already to 180, -180, but it still follow the character backwards.