- Home /
User-Placeable Objects
Does anyone have a script bit for an OnGUI function, so that OnGUI the game clones a specific prefab and places it into the world a specific distance in front of the player, so that, for example, the user can select a skyscraper from a menu and drop it into the world?
This sounds more like you want someone to build part of your game for you. If your looking for some complete item like this, you may want to check the Asset Store. Or you may google tutorials on similar subjects and extrapolate
No, I simply need to know how to instantiate a prefab and place it a specific distance in front of you. I already have a prefab. Also, the reason why I am asking this is because I have already googled this and found 3 answers, none of which were relevant.
Thanks. Please post as an answer so that I can mark it as so, and give you a thumbs up.
Answer by robertbu · Jul 29, 2013 at 07:07 PM
For the specific question of cloning some distance in front of an objects position:
Instantiate(someObject, transform.position + transform.forward * someDistance, transform.rotation);
@$$anonymous$$eus64 If you need to know how to do something this basic, usually someone will direct you to the Unity Script Reference, where you would be able to search for Instantiate and find what you need to know. You can usually figure it out faster this way than waiting on a legit answer like this one. And if you ask "Does anyone have a script" or "write me a script" or pretty much anything else making it look like you want someone to do the work for you, some people downvote you. Not trying to badger you, just giving advice. Happy developing.
@robertu +1
Your answer
Follow this Question
Related Questions
Simple Menu(understanding GUI) 2 Answers
Individually rotate GUI Elements? 4 Answers
user add on screen text 2 Answers
How to use GUIUtility.hotControl? 0 Answers
How to make a Cube act as a button to increment a number on a screen overlay panel in an FPS? 1 Answer