Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class RayCastTest : MonoBehaviour {
  5. private RaycastHit hit;
  6. private float range = 300f ;
  7. public GameObject decal;
  8.  
  9. // Use this for initialization
  10. void Start () {
  11.  
  12. }
  13.  
  14. // Update is called once per frame
  15. void Update () {
  16. if (Input.GetMouseButtonDown (0)) {
  17.  
  18. Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
  19. if (Physics.Raycast (ray,out hit,range)){
  20. Debug.Log ("Hit");
  21. Instantiate(decal,hit.textureCoord,Quaternion.FromToRotation(Vector3.up, hit.normal));
  22. }
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement