Easy Way To Get TileIndex At Set Position

Discuss modding questions and implementation details.
Post Reply
l3lessed
Posts: 1399
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Easy Way To Get TileIndex At Set Position

Post 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.
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

User avatar
BadLuckBurt
Posts: 948
Joined: Sun Nov 05, 2017 8:30 pm

Re: Easy Way To Get TileIndex At Set Position

Post 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
DFU on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
DFU Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

.

Post Reply