Jump to content

How to get the closest object above an actor (script)


SAC020

Recommended Posts

 

So, there is the "GetNearestRefofType" function (or something similarly named), which returns the closest object around an actor, within a sphere. What I a looking for is a script which returns the object directly above the actor (or the sky, if none).

 

Any ideas?

 

Thanks

Link to comment
Share on other sites

There is no function, but its straight forward logic to cycle through the return/array from FindAll..() and compare the actor's XYZ position with found objects XYZ position to identify something with zero (well a little) X or Y and some Z height.

Link to comment
Share on other sites

There is no function, but its straight forward logic to cycle through the return/array from FindAll..() and compare the actor's XYZ position with found objects XYZ position to identify something with zero (well a little) X or Y and some Z height.

 

Thank you, I thought of that, but I don't know how to work with arrays

Link to comment
Share on other sites

this should do ya (although if its WTF do I do with that now, best leave it).

ObjectReference[] FoundStuff = ThisActorREF.FindAllReferencesOfType(ThisItemType, 2048.0)

Int iIndex = 0 
While iIndex < FoundStuff.Length
   ObjectReference ThisItem = FoundStuff[iIndex]
   If (Math.ABS(ThisItem.GetPositionX()) - Math.ABS(ThisActorREF.GetPositionX() < 32)
      If (Math.ABS(ThisItem.GetPositionY()) - Math.ABS(ThisActorREF.GetPositionY() < 32)
          If ThisItem.GetPositionZ() > ThisActorREF.GetPositionZ()
            ;ThisItem is directly above ThisActorREF
         Endif
      Endif
   Endif
   iIndex +=1
EndWhile
Link to comment
Share on other sites

 

this should do ya (although if its WTF do I do with that now, best leave it).


 

Thank you very much!

 

I am guessing that indoor it will return the position of the building, not the ceiling? Or, in case of a tree, the base of the tree

 

I'll try spawning a mwst above the character and see where it falls

Link to comment
Share on other sites

You will need to define ThisItemType as the BaseObject or form list of Base Objects of whatever it is you are looking for: roofing pieces, hats, dragons, vertibirds, whatever. You cant run a search on *everything* or *anything*.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...