here my code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DestinationChange : MonoBehaviour
{
public int xPos;
public int zPos;
void OnTriggerEnter(Collider other)
{
if (other.tag == "Enemy")
{
xPos = Random.Range(64, 431);
zPos = Random.Range(45, 442);
this.gameObject.transform.position = new Vector3(xPos, 1.5f, zPos);
}
}
}
,this my script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DestinationChange : MonoBehaviour
{
public int xPos;
public int zPos;
void OnTriggerEnter(Collider other)
{
if (other.tag == "Enemy")
{
xPos = Random.Range(64, 431);
zPos = Random.Range(45, 442);
this.gameObject.transform.position = new Vector3(xPos, 1.5f, zPos);
}
}
}