Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class AIController : MonoBehaviour
- {
- public Transform Player;
- int MoveSpeed = 4;
- int MaxDist = 7;
- int MinDist = 3;
- private Vector3 newPosition;
- public Transform otherTransform;
- void Start()
- {
- var relativePoint = transform.InverseTransformPoint(otherTransform.position);
- if (relativePoint.x < 0.0)
- {
- print("Object is to the left");
- }
- else if (relativePoint.z > 0.0)
- {
- print("Object is to the right");
- }
- else
- {
- print("Object is directly ahead");
- }
- }
- void Update()
- {
- //transform.LookAt(Player);
- if (Vector3.Distance(transform.position, Player.position) >= MinDist)
- {
- newPosition = Player.position;
- transform.position = Vector3.Lerp(transform.position, newPosition, Time.deltaTime * MoveSpeed);
- if (Vector3.Distance(transform.position, Player.position) <= MaxDist)
- {
- //Shoot();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement