Dynamically spawning place markers


I am currently looking to re-design the way in which placements points are spawned into the game. These are the points in 3D space the player can place items for example, placing a chopping board on a work surface. 

In this version, they are determined before the game loads - which obviously is highly inefficient. The new system I have written allows these points to be placed dynamically - i.e on game load. 

The supporting screenshot shows the new function:

  •  Creates a 2d array using the scale in the x and z axis for how many place points will be spawned. 
  • Loops through the array, getting the correct position on the object.
  • A position is then set by instantiating a new object 'Cell' and using the method 'SetPosition(position)'.
  • Finally, the new object is then assigned to that instance in the array

This function is great as each position is set according to the objects dimensions, so each point is spawned in a uniform location. However, if the dimensions of the object are decimal points (e.g 3.5 by 2.5) then points are not uniform. Additionally, as an array size cannot be a decimal point, an error is thrown. Therefore some error handling will need to implemented. 

Get Cooking With Polygons

Leave a comment

Log in with itch.io to leave a comment.