Page 1 of 1

Easy Way To Get TileIndex At Set Position

Posted: Tue Sep 28, 2021 7:24 pm
by l3lessed
Real quick question, I have random vector3 coordinates being created for my basic 3d animal roaming behavior. The behavior is working fine. The anima wonders aimlessly within a set bound range, which also checks for collisions before setting it up.

However, I wanted to check the tile under them real quick, so I could keep them from walking over water or wandering to far into public roads. It is real easy to do with the player because of the built in objects for this. However, I can't find anything similar for a random vector3 position. Is there anything I'm missing the the API for this? I want to drop in the next move location vector3 position and get back the tile index it is on.

Re: Easy Way To Get TileIndex At Set Position

Posted: Tue Dec 28, 2021 2:26 pm
by BadLuckBurt
I think you'd need to code this yourself, if you look at the three methods in StreamingWorld.cs that I mentioned below, you can see how it's done for the player. If it only applies to the map pixel the player is currently in, you can lift a lot of the code directly from UpdatePlayerTerrainTileIndex. You'd just need to provide a different relativePos value which would be the vector you want to check.

Code: Select all

StreamingWorld.cs:

UpdatePlayerTerrainTileIndex
GetPlayerTerrain
GetPlayerTerrainTransform