Jump to content

Check for conflicts when placing stationary objects?


Recommended Posts

I'm designing an item which, upon use, spawns and places several stationary objects at random locations within a certain distance of the player.  For the sake of example, let's say they're trees.

 

I want to make sure they aren't placed in invalid locations (on top of a boulder or pond, in the ocean, etc.).  Before I write code to check this myself, I'm wondering if there's an existing facility for this, something like

 

IsValidLocation( x, y, z, ... )

 

Is there such a thing?

 

Thanks in advance for your help!

 

 

Link to comment
Share on other sites

@keraunoscopia,

local can = TheWorld.Map:CanPlacePrefabFilteredAtPoint(x, y, z, prefab)

x, y, z a world position (like inst.Transform:GetWorldPosition()).

prefab being "berrybush", or "axe", for example.

 

This is for ground types.

 

For spacing between stuff:

local can2 = TheWorld.Map:CanDeployRecipeAtPoint(pt, recipe)

pt being a position (like inst:GetPosition()).

recipe being a recipe, you want to leave it at nil to use the 3.2 min_spacing separator.

Edited by DarkXero
Link to comment
Share on other sites

@keraunoscopia,

local can = TheWorld.Map:CanPlacePrefabFilteredAtPoint(x, y, z, prefab)

x, y, z a world position (like inst.Transform:GetWorldPosition()).

prefab being "berrybush", or "axe", for example.

 

This is for ground types.

 

For spacing between stuff:

local can2 = TheWorld.Map:CanDeployRecipeAtPoint(pt, recipe)

pt being a position (like inst:GetPosition()).

recipe being a recipe, you want to leave it at nil to use the 3.2 min_spacing separator.

Excellent - thanks very much for your response!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...