Ikedude Posted April 21, 2013 Share Posted April 21, 2013 Is there an easy way to find the closest object of any type? I found these: http://www.creationkit.com/FindClosestReferenceOfAnyTypeInList_-_Game http://www.creationkit.com/FindClosestReferenceOfType_-_Game but I just want the closest object of any type. I guess I could fill in the FormList with a limited set, but I feel like there has to be a better way. Thanks Link to comment Share on other sites More sharing options...
gsmanners Posted April 21, 2013 Share Posted April 21, 2013 The problem with *the* closest object is that it will likely be a light or fx or a static of some kind, and I doubt you really want to mess with that. Here's some sample code of what you can do: FormList Property OwnerList Auto ... Actor player = Game.GetPlayer() ObjectReference p = Game.FindClosestReferenceOfAnyTypeInListFromRef(OwnerList, player, 2048) if (p != none) if (p.GetActorOwner() != player.GetActorBase()) p.SetActorOwner(player.GetActorBase()) endif endif Link to comment Share on other sites More sharing options...
Ikedude Posted April 21, 2013 Author Share Posted April 21, 2013 For my usage it will be in reference to another object, not the player, so hopefully it will return the object I actually want. To check if it is something I want to mess with I'm planning on using GetMass, if it returns zero then I'll leave it alone. It might actually be more useful to get a FormList of all objects within a specific radius, then I could iterate through them... no idea how to get that though, ha. Link to comment Share on other sites More sharing options...
gsmanners Posted April 21, 2013 Share Posted April 21, 2013 If you don't mind using SKSE, there is http://www.creationkit.com/GetNthRef_-_Cell Link to comment Share on other sites More sharing options...
Recommended Posts