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
- [GreaseMonkey] Unity Forum Fixer
- UnityHub: Make Hub application background Translucent
- Customize SpriteShapeRenderer quality (but has issues)
- Editor tool: Copy selected gameobject’s names into clipboard as rows (for Excel)
- Editor tool: Replace string in selected gameobject’s names
- UnityHub: Enable built-in Login Dialog (no more browser login/logout issues!)
- Use TikTok-TTS in Unity (with WebRequest)
- Create Scene Thumbnail Image using OnSceneSaved & OnPreviewGUI
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
- Custom Unity Hub Project Template Preview Image/Video (using HTML+CSS in package description)
Recent Comments
- Vector3 maths for dummies! on
- UnityHub: Make Hub application background Translucent on
- UnityHub: Make Hub application background Translucent on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- [Asset Store] Point Cloud Viewer & Tools on
- [Asset Store] Point Cloud Viewer & Tools on
- ffmpeg stream raw video into Unity Texture2D on
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