Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class cameraRaycast2 : MonoBehaviour {
- public LayerMask atuacaoRaycast;
- public GameObject objeto;
- private RaycastHit[] alvos;
- // Update is called once per frame
- void Update () {
- alvos = Physics.RaycastAll (transform.position, transform.forward, 100, atuacaoRaycast);
- if (alvos.Length > 0) {
- Debug.DrawLine (transform.position, alvos [alvos.Length - 1].point);
- if (Input.GetMouseButtonDown (0)) {
- foreach (RaycastHit alvo in alvos) {
- if (alvo.transform.name == "alvo") {
- Instantiate (objeto, alvo.point-transform.forward*0.5f, Quaternion.LookRotation (alvo.normal));
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement