Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class SpawnObject : MonoBehaviour
- {
- public Object Player;
- public GameObject prefabToSpawn;
- private void Update()
- {
- if (Input.GetKeyDown(KeyCode.Mouse0))
- {
- RaycastHit _hit;
- Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
- if (Physics.Raycast(ray, out _hit))
- Instantiate(prefabToSpawn, new Vector3(_hit.point.x, _hit.point.y, _hit.point.z), transform.rotation);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement