How can i spawn a sprite over a plan surface where i click

https://playcanvas.com/project/967879/overview/pz-test

I’m creating a House planner for a game, so i need to spawn the sprites over a planer or a height, actually i’m using box-spawn without physic example for this, but doesn’t work how i want!

What do you mean by planer/planner?

Can you give the steps needed to show the error and also a screenshot of what you mean please?

1 Like

A flat surface, i wanna click in a surface and can spawn a sprite, actually when i click only spawn a object in a distance from camera, not exactly over the surface

Hi @fafato1,

Check this example, on click it spawns an cube entity over the surface. You can update the code to place a sprite entity instead.

https://developer.playcanvas.com/en/tutorials/place-an-entity-with-physics/

2 Likes

In this case, you know how far on the Z axis the the background tiles are since they are based on tile X and Y values.

What you will have to do is work out what tile X and Y is being hit based on where you have clicked.

This is what I do with my isometric project: https://playcanvas.com/project/560025/overview/isometric-base-builder

Alternatively, you can use physics collision or bounding boxes as something for raycasts to test against and get the intersection point on where they hit to place entities on top.

2 Likes

I liked your way to build, have a way to build in multi layer?

What do you mean by multi layer?

1 Like

Do you know a game Called Project Zomboid? in game you can build 32 floors of height, i’m making a house planner for this game!

In which case, yes you can use multi layers with my project but you will have to add the logic yourself. It’s currently doesn’t support that

1 Like

What would be the best way to import the build system you made? it’s a lot of files!

Could you help me?

Its wasn’t designed or written for to be easily used in another project.

I’m afraid you will have understand the project as a whole in order to add the extra functionality on top or to pull out the logic you need

1 Like