- Home /
Having trouble cleaning up behind player in infinite runner
I have a giant trigger following the player with a "Vacuum" tag. Whenever it touches something I destroy the game object and that part is working fine. However, some of the things explode and fly off way out of the range of the vacuum so I'm trying to destroy them when they fall below a certain y value but it's not working and I can't figure out why.
Thanks in advance if you can help!
using UnityEngine;
using System;
using System.Collections.Generic;
using System.Collections;
public class CleanUp : MonoBehaviour
{
void update()
{
if (gameObject.transform.position.y < -5f)
{
Destroy(gameObject);
Debug.Log("Cleanup Working!");
}
}
// Update is called once per frame
public void OnTriggerEnter(Collider collisionInfo)
{
if (collisionInfo.tag == "Vacuum")
{
Destroy(gameObject);
}
}
}
Answer by xxmariofer · Jun 04, 2019 at 08:07 PM
Because you misspelled Update with a capital letter
Oh, haha! That was such a silly mistake. Thank you, works now!!
Your answer
Follow this Question
Related Questions
Moving a GameObject to a certain point in world space via script 1 Answer
How do i move a GameObject to the same height as another GameObject? 0 Answers
TriggerExit not working as intended/Transforming GameObject Problems 0 Answers
Character rotation and move to mouse click point with speed 0 Answers
How to keep gameobject transform relative to parent 1 Answer