Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class CutFruitOnClick : MonoBehaviour
  6. {
  7.     // Start is called before the first frame update
  8.     void Start()
  9.     {
  10.       Debug.Log("START Hej fra cut fruit on click");
  11.     }
  12.  
  13.     // Update is called once per frame
  14.     void Update()
  15.     {
  16.         if (Input.GetMouseButtonDown(0)) {
  17.             Debug.Log("Venstre Museklik");
  18.             Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
  19.             RaycastHit hit;
  20.  
  21.             if (Physics.Raycast(ray, out hit, 100)) {
  22.                 if (hit.transform == this.transform) {
  23.                     GetComponent<ParticleSystem>().Emit(5);
  24.                 }
  25.             }
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement