- Home /
Question by
DuszpasteX_studios · Apr 03, 2021 at 11:59 AM ·
transformbugcursorscreentoworldpointfollowing
Camera.main.ScreenToWorldPoint not working
void Update()
Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
transform.position = new Vector3(0, mousePos.y, 0);
is not working its following only camera transform, but i want to make it following cursor in y axis. main camera has script to move:
void Update()
{
if (Input.GetKey(KeyCode.Space))
{
transform.Translate(0, cameraspeed * Time.deltaTime, 0);
}
if (Input.GetKey(KeyCode.LeftShift))
{
transform.Translate(0, -cameraspeed * Time.deltaTime, 0);
}
if (Input.GetKey(KeyCode.W))
{
transform.Translate(0,0, cameraspeed * Time.deltaTime);
}
if (Input.GetKey(KeyCode.S))
{
transform.Translate(0, 0, -cameraspeed * Time.deltaTime);
}
if (Input.GetKey(KeyCode.A))
{
transform.Translate(-cameraspeed * Time.deltaTime, 0, 0);
}
if (Input.GetKey(KeyCode.D))
{
transform.Translate(cameraspeed * Time.deltaTime, 0, 0);
}
Comment