Wednesday, July 6, 2022
HomeGame Developmentunity - How one can test if recreation object is in a...

unity – How one can test if recreation object is in a set off space


I’ve a 2nd tilemap collider mixed with a 2nd composite collider to and set to be a set off. What I wish to do is test if there are any recreation objects inside that set off space. The catch nevertheless is that not all of those recreation objects have colliders. I can’t use collider bounds both for the reason that set off space may be wrapped round recreation objects with out them being in it (see image). At this level I’ve a listing of recreation objects (bought them by tag identify), and I am looping via them to test if they’re within the room.

For extra context, that is what is occurring from the participant’s perspective: You are coming into a procedural generated dungeon, the scene masses, and all the sport objects are loaded with the scene (chests, stairs, factors of curiosity, and so on…). The dungeon is split into sections, and because the participant walks round and enters sections of the map (coming into the set off), that calls the strategy to seek out all of the gameobjects of a sure tag identify and test if they’re within the set off space to allow them to be proven on the map when the participant enters that space.

    public void ShowMapIconsInExposedRoom(Collider2D roomCollider)
    {
        foreach(GameObject go in MapIconGameObjects)
        {
            if (/*recreation object is within the room collider*/)
            {
                go.SetActive(true);              
            }
        }
    }

TriggerArea

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments