So like some game I’m trying to make it to were when you get close to Xp the Xp follows you and destroys it self when it hits your collider. I really just need help on how to make it follow you but if you know how to destroy it when it hits the player collider that would be helpful.
Attach a trigger and a collider to the xp and a rigidbody(check kinematic box). trigger should be larger than collider. then add this code.
xp script
public Transform player;
bool isFollowing = false;
void Update()
{
if (isFollowing)
transform.positon = Vector3.Lerp(transform.position, player.position, 1 * time.deltaTime);
}
void OnTriggerEnter(Collider other)
{
if (other.transform.tag == "Player")
isFollowing = true;
}
Void OnCollisionEnter(Collision other)
{
if (other.transform.tag == "Player")
Destroy(gameobject)
}