Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - using UnityEngine;
 - using System.Collections;
 - public class cursorController : MonoBehaviour {
 - public GameObject cursor00;
 - public GameObject cursor11;
 - public GameObject mouse00;
 - public GameObject mouse11;
 - public GameObject mouseModel;
 - Vector2 mapMouse(Vector3 screenZero, Vector3 screenOne, bool useZ){
 - Vector2 mouse = new Vector2(Input.mousePosition.x/Screen.width, Input.mousePosition.y/Screen.height);
 - float cursorX = Mathf.Lerp(screenOne.x, screenZero.x, mouse.x);
 - float cursorY;
 - if(useZ){
 - cursorY = Mathf.Lerp(screenZero.z, screenOne.z, mouse.y);
 - }
 - else{
 - cursorY = Mathf.Lerp(screenZero.y, screenOne.y, mouse.y);
 - }
 - return new Vector2(cursorX,cursorY);
 - }
 - // Update is called once per frame
 - void Update () {
 - //Cursor
 - Vector2 cursor = mapMouse(cursor00.transform.position, cursor11.transform.position, false);
 - transform.position = new Vector3(cursor.x,cursor.y, transform.position.z);
 - //mouse
 - Vector2 mousePos = mapMouse(mouse00.transform.position, mouse11.transform.position, true);
 - mouseModel.transform.position = new Vector3(mousePos.x, mouseModel.transform.position.y, mousePos.y);
 - }
 - }
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment