Hello!
I’m currently working on a farming game. I wish for the player to be able to place down tree seeds so long as there isn’t any items within each of the four directions. I’ve tried many ideas but done have worked. This is what I have now, any ideas?
Thanks!
A simple way is to check the space before you place the seed. Try using a slightly larger invisible placement zone around the seed and only allow planting when that zone is not touching another object. That keeps the spacing rule in one place instead of checking four directions separately.
I would, but I still want to allow placement if an item is touching the seed diagonally.
think outside the box!
an angled hitbox overalaps the sides but not corners. in fact you could use any hitbox shapes.
additionally, if you want super fast performance:
this diamond shape is exactly the same as the radius in taxicab geometry
|x1 - x2| + |y1 - y2|
if you go for the hitbox method. pick them using point is inside instead of collision
if centerX,centerY is inside hitbox
though the the fastest is taxicab