im new here… please take consideration of me…
heres is what the script is gonna be…
the player clicks anywhere from the game window and a prefab/3d model/object get created on that place…
:)
:p:o;)![]()
![]()
:-|8-):razz:
im new here… please take consideration of me…
heres is what the script is gonna be…
the player clicks anywhere from the game window and a prefab/3d model/object get created on that place…
:)
:p:o;)![]()
![]()
:-|8-):razz:
Welcome,
Though your request is rather vague, you must first ask yourself a question. Are we clicking on something, or is it just someplace in space?
If you are clicking on something, then you will need a physics Raycast from the screen location to that object, then you will need to define how that object orientates its self to the click position.
If it is just a blank space, you will need a Plane Raycast, but it will still require that you orientate the object to the position.
Both are easily done and the documentation can help, we just need to know how you want to go about this task.
Hey James,
Just look into Physics.Raycast and RaycastHit on the Unity scripting reference section of their site:
http://unity3d.com/support/documentation/ScriptReference/index.html
For creating at a prefab, just look for Object.Instantiate.
For mouse input and positioning on the screen look for Input.mousePosition (This one actually has a very good example for your specific issue):
http://unity3d.com/support/documentation/ScriptReference/Input-mousePosition.html
Oh, and welcome ![]()
I presume you are making a level editor. I can tell you how I am making my basic 2D level editor.
I basically have grid pieces that I raycast, and if I hit one, the selected object is instantiated on the same x and y axis with the z axis being ahead a few units to make sure they are on top of the grid.
i am not making any level editor… its an RPG kind of game… the player click on the terrain then a object gets created and the player follows it. i know how to use the object.instantiate and input.mousePosition yet, using input.mouse position wont work, is there another way?
you need to get back the position you clicked on your terrain , and those are handled with ray cast and function like camera.ScreenPointToRay etc…
http://unity3d.com/support/documentation/ScriptReference/Camera.html
look in function here, you should get around your issue, also if you are not doing any iOS stuff , i think there is some OnMouse something available
that could be of use maybe too.
but basically you fire a ray from your input on screen and in the direction where you look at , then when the ray hit your ground you get the 3d coordinate and well do your stuff then.
so the link provide useful function to achieve this
Artr in fact already gave you what you need to look into ![]()
can you just type in the script here, im kind of a newbie… please
please…
can you just type in the script here, im kind of a newbie… please