I am trying to get this object to move with the cursor on a 2D axis.
(It’s the red cross hairs). This is the C# script I made for it:using UnityEngine;
using System.Collections;
public class Player_Curser_Movement : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Vector3 temp = Input.mousePosition;
temp.z = 5f;
transform.position = temp;
}
}
I had it print out the x, y, and z coordinates of the object, when my cursor was over the center, it said the coordinates were around: 436, 244, 5. When my mouse is in the bottom left corner of my screen it puts the object around the middle of the screen, but it’s very sensitive to movement.