W
W
WasTabon2022-02-12 13:12:39
Unity
WasTabon, 2022-02-12 13:12:39

What causes an object to fly away on the z-axis by -10?

Mortire.transform.position = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y , 0));

620787f4e147e504860773.png
If you use this
float mouseY = Input.GetAxis("Mouse Y");
float mouseX = Input.GetAxis("Mouse X");

That micro movement with the mouse and my object already begins to pass the 4th dimension

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
WasTabon, 2022-02-13
@WasTabon

Vector3 mousePosition = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10f);
Vector3 objPosition = Camera.main.ScreenToWorldPoint(mousePosition);
Mortire.gameObject.transform.position = objPosition;

N
Nikita Kargin, 2022-02-12
@Pakonigoosy

Just try

Mortire.transform.position = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y , 0));
Mortire.transform.position.z=0;

Or does it not work like that?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question