using UnityEngine;
using System.Collections;
public class Basket : MonoBehaviour
{
void Update ()
{
// Get the current screen position of the mouse from Input
Vector3 mousePos2D = Input.mousePosition;
// The Camera's z position set the how far to push the mouse into 3D
mousePos2D.z = -Camera.main.transform.position.z;
// Convert the point from 2D screen space into 3D game world space
Vector3 mousePos3D = Camera.main.ScreenToWorldPoint (mousePos2D);
// Move the x position of this Basket to the x position of the Mouse
Vector3 pos = this.transform.position;
pos.x = mousePos3D.x;
this.transform.position = pos;
}
}
I am currently learning c# from a book. This is the one of the code inside. Can someone explain the content in void update? The book didnt explain it clearly to newbies like me, so plz help me. Thank you