- Home /
dont work maxdistance
don't work if(Vector3.Distance(taikinys.position, transform.position) > maxDistance){ /// kazkas transform.position += transform.forward judesiogreitis Time.deltaTime;
Sript
using UnityEngine; using System.Collections;
public class PriesoAI : MonoBehaviour { public Transform taikinys; public int judesiogreitis; public int rotationgreitis; public int maxDistance;
// Use this for initialization void Start () { GameObject go = GameObject.FindGameObjectWithTag("zaidejas"); taikinys = go.transform; maxDistance = 4; }
// Update is called once per frame void Update () { Debug.DrawLine(taikinys.position, transform.position, Color.yellow); //ziureti i taikini transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(taikinys.position - transform.position), rotationgreitis Time.deltaTime); if(Vector3.Distance(taikinys.position, transform.position) > maxDistance){ /// kazkas transform.position += transform.forward judesiogreitis * Time.deltaTime; } } }
Format your code otherwise it'll be very unlikely that you'll get an answer.
Please format your code!!! I can't read that and I bet neither can you!!!
why don't need print both distances to see what you are comparing, obviously one of them is wrong