Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Control : MonoBehaviour
- {
- public Vector2 mousePos;
- public Transform mouseFollow;
- public bool mouseTouch = false;
- public void Update()
- {
- mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
- mouseFollow.transform.position = mousePos;
- if (Input.GetMouseButton(0))
- {
- if (mouseTouch)
- {
- transform.position = mousePos;
- }
- }
- }
- private void OnTriggerEnter(Collider other)
- {
- mouseTouch = true;
- }
- private void OnTriggerExit(Collider other)
- {
- mouseTouch = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment