Advertisement
Guest User

yuny helpy

a guest
Jan 16th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.44 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class SpawnObject : MonoBehaviour
  5. {
  6. public Object Player;
  7. public GameObject prefabToSpawn;
  8. private void Update()
  9.  
  10. {
  11.  
  12.  
  13. if (Input.GetKeyDown(KeyCode.Mouse0))
  14. {
  15. RaycastHit _hit;
  16. Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  17. if (Physics.Raycast(ray, out _hit))
  18. Instantiate(prefabToSpawn, new Vector3(_hit.point.x, _hit.point.y, _hit.point.z), transform.rotation);
  19. }
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement