Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Detecting Size of Tile Object in TileMap

ms07ms07 Member
edited July 28 in Programming

Hello Guys/Girls . I want to detect size of that tile (platform) under that zombie character with collision. so i can use its size for making patrols. can any one point me into right directions..?

I am using Unity 3d Engine 2020 and that Platform is a Part of Unity Tile Map.

Screenshot : -


  • MouledouxMouledoux Member
    edited July 27

    Through its renderer, you can get a bounding box.

    More info here:

    and here:

    To get the edge, I think you have to do something like:

    Vector3 bottomLeft = GetComponent<Renderer>().bounds.min;

    This would give you the lower left corner as a Vector3. I do not know if this is in world or screen space though, so this next part you may have to experiment with. Basically to get the edge at the center of the road, you need to bump it up to the same Y as your zombie in this case. If it is a perfect, non-rotated rectangle, you could maybe get it by adding the difference of the max Y and the min Y.

    Edit 1: Just checked the docs, the bounds are in world space.

    Edit 2: Alternative solution, your zombie could check if it has reached the edge, by casting a ray down and in front of itself. If it collides with nothing, or something else like a barrier, you could turn it around then.

  • ms07ms07 Member
    edited July 28

    @Mouledoux thank you for replying but its part of Tile map not a standalone object.. ...thats what my problem is how to access single tile in a tile map...?

  • Then I would just go with my 2nd suggestion, and do a ray cast to check for colliders.

  • ms07ms07 Member

    @Mouledoux means no chance for getting x and y size with bounding box :/

  • I actually don't know tile maps enough to say for sure. But unless you NEED the x and y size, I would just do a ray cast.

  • ms07ms07 Member

    @Mouledoux Thank You :)

Sign In or Register to comment.