Advertisement
Guest User

PlaceCube.cs

a guest
Sep 6th, 2018
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class PlaceCube : MonoBehaviour
  6. {
  7.     // Use this for initialization
  8.     void Start ()
  9.     {
  10.        
  11.     }
  12.    
  13.     // Update is called once per frame
  14.     void Update ()
  15.     {
  16.         if(Input.GetMouseButtonDown(0))
  17.         {
  18.             Vector2 screenpos = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
  19.             Vector3 worldpos;
  20.             if(ZEDSupportFunctions.GetWorldPositionAtPixel(screenpos, ZEDManager.Instance.GetLeftCameraTransform().GetComponent<Camera>(), out worldpos))
  21.             {
  22.                 GetComponent<Rigidbody>().velocity = Vector3.zero;
  23.                 transform.position = worldpos + Vector3.up;
  24.             }
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement