Sorry for my bad english…
i want when you left click, you spawn a object on the mouse position… and i want to have a kind of shadow… that will show a preview of my object in space but i dont know how to do it… (take me easy… i am at the begiming)
Lets start from the beginning,
Is it a 2D or 3D game?
Its a 3d game… i manged to create a camera that moves around a empty object when right click.
And that is everything i managed to do so far
A screenshot would be great if you could supply one, it would help with me getting the image into my head.
Anyway, if it is set up like I think it is then you could fire a raycast and where it hits the cube, it could spawn the object.
I had a quick search on the Unity Docs and found a great page which sounds like its exactly what you want.
The example if perfect as it is firing a raycast and spawning an object, you just need to change the GameObject, and where the object is Instantiated to where the raycast hits.
well there is not much…
a empty object in the middle and a camera that orbits around it
well i tried the raycast script but where do i need to atach it?..
it seems that i cant make the object to spawn at the mouse position…
ok… i managed to do this but the object i want to spawn spawns around the world spawns all
using UnityEngine;
using System.Collections;
public class PlankCreator : MonoBehaviour {
public GameObject particle;
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray))
Instantiate(particle, Input.mousePosition, transform.rotation);
}
}}
from this image, it seems that the cubes i want to spawn in the world are making a wall… i mesed up something in code… i think what i have done would be usefull in 2d…