Spawn object where you click

I need help I’m trying to make code where when you click an object spawns where you click

If you would like to spawn a drawing object like a cube or sphere, you can use the following code:

Time.scheduleRepeating(() =>{
const rayCastHit = RayCast.cast( Camera.transform.position , Input.clickDirection );
if (rayCastHit && rayCastHit.item.name == “ground”){
Input.onKeyPressed(()=>{let cube = Scene.createCuboid(rayCastHit.point)},“left_mouse_button”);
} }

But if you would like to spawn BaseItems or other objects, you will need to hide the original somewhere and spawn its copies on the click position.
I hope this example is helpful: JRZ-BDC

1 Like