hi everyone! i have a little problem… i have a 3d game and i want to create a object at mouse position in the 3d space… to make a game like the sims but when i try the code, when i click it spawns the object in another place… i dont know what is hapening
using UnityEngine;
2.using System.Collections;
3.
4.public class PlankCreator : MonoBehaviour {
5.
6. public GameObject particle;
7. void Update()
8. {
9. if (Input.GetButtonDown("Fire1"))
10. {
11. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
12. if (Physics.Raycast(ray))
13. Instantiate(particle, Input.mousePosition, transform.rotation);
14. }
15. }}
16.