13
2012
Place Objects on Space With Mouse
If you want to instantiate objects on empty space, you cannot use Raycasts (no colliders to hit).
But you can use ScreenToWorldPoint() with adjustable distance from camera.
(Or you could put invisible collider there..and if you need to adjust distance, move the collider..)
Webplayer:
http://unitycoder.com/upload/demos/PlaceObjectsOnSpace/
Download source:
instantiateAtSpace.unityPackage
Related Posts
2 Comments + Add Comment
Leave a comment
Recent posts
- Adding Real World Location to Ice Fishing Prototype
- [web tool] Image Channel Inspector : AlphaScope
- Editor Tool: Smart Recompile (don’t recompile if edit comments)
- Editor Tool: Scene Size Analyzer
- LudumDare 60: Old Tech
- uBasic Scripting Language for Unity
- GreaseMonkey+Editor Plugin: 1-Click Copy script from ChatGPT (Web) to Unity Editor (as script)
- Editor Tool: Property Watcher
- .unityignore : Hide files from Project window
- PostBuild Script to Create Single exe Standalone File
- Game Loop Designer
- Favorites in PackageManager
Recent Comments
Coin:
CUgDSbRqFcAumDSAcdKDvuXsw26VdkJe8C8WGUQHBAGS
An article by













I struggled with this a while back. Any way to prevent cubes from being build inside other cubes, without using an invisible collider out in front of the camera?
The idea is a first person shooter, with some base building. So having a collider out in front seemed to basically act a shield to enemy fire.
some ideas to try,
– If you use grid, then keep array of filled grid cells, so cannot place on them
– Or, if no grid, keep list of objects and check if user tries to insert new object too close to existing (radius, check each building from list (basically find nearest and calculate distance)
– Or have colliders/triggers, and then use layers to disable bullets from colliding on them