Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class PlacingObjects : MonoBehaviour {
- [SerializeField] GameObject obj;
- void Update(){
- if(Input.GetMouseButtonDown(0))
- CreateObject(MousePosition);
- }
- void CreateObject(Vector3 position){
- Instantiate(obj, position, Quaternion.identity, transform);
- }
- Vector2 MousePosition{
- get{
- Vector2 worldPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition);
- return worldPoint;
- }
- }
- /* berkinakkaya.wixsite.com/blog */
- }
Advertisement
Add Comment
Please, Sign In to add comment