Jump to content
Einlander

How to find if an entity is in another objects aabb?

Recommended Posts

I've been making a AI spawning system and I'm finding that there are situations where the spawn location ends up in another entity. I would like to be able to programmatically detect this and move the spawn location. How would I go about this?

Share this post


Link to post

i taught of this :

get all positions of all entities as a vec3 and then check for x and z .

if those are equalling under (for example 10) then add a new random value to the spawning point.

all this before a new monster gets spawned and make sure the things above get checked as often as if there isnt an other entity around.

Share this post


Link to post

After some leaps of faith I have come up with a fascinating solution. I used the GetEntityNeighbors.lua file found in the functions folder. I set the entity as itself (i'm using a pivot), with a radius of 0 and false for the scripts parameter. Sadly this will only tell you the outermost object of what you are in. So if you walk in a building in your game, it will return the building entity.

 

Is there a way to return the innermost entity you are in, if you are in one? For you place an entity inside a box, that's inside a safe?

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...