Advertisement
Guest User

Untitled

a guest
Aug 25th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.56 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Raketa : MonoBehaviour
  6. {
  7.     public Rigidbody2D rb;
  8.  
  9.     private bool isPressed = false;
  10.     private void Update()
  11.     {
  12.         if (isPressed)
  13.         {
  14.             rb.position = Camera.main.ScreenToViewportPoint(Input.mousePosition);
  15.         }
  16.     }
  17.     private void OnMouseDown()
  18.     {
  19.         isPressed = true;
  20.         rb.isKinematic = true;
  21.     }
  22.     private void OnMouseUp()
  23.     {
  24.         isPressed = false;
  25.         rb.isKinematic = false;
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement