C# Mathf.Round Not Rounding Input.mouseposition
I'm trying to create a script that makes the scripted gameobject follow the mouse and round it's position. However when I played the scene the Input.mouseposition.x and Input.mouseposition.y weren't rounding even though I put them through the Mathf.Round function. Any ideas why they aren't rounding? This almost seems like a bug.
transform.position = Camera.main.ScreenToWorldPoint(new Vector3(
Mathf.Round(Input.mousePosition.x),
Mathf.Round(Input.mousePosition.y),
transform.position.z));
* Isn't there a more pressing matter here? *
Input.mousePosition returns the pixel number on the viewport of its position. These will always be whole numbers, so rounding them won't accomplish anything.
If the idea is the round the resulting position, then it needs to be handled by getting the position using mousePosition, THEN rounding the values to the nearest whole numbers.
What's actually wrong with the program? What should be happening that isn't? Do you want to round the result to the nearest int?
(Also, moved to HelpRoom, where help with learning program$$anonymous$$g and Unity are best.)
Your answer
Follow this Question
Related Questions
Get coordinates of mouse-click on plane 1 Answer
Shooting a projectile with Isometric View 0 Answers
Get Velocity of Rigidbody Object Below Another Object 0 Answers
Shooting a bullet towards the mouse 0 Answers
How to find the transform position of another gameobject then move a gameobject to that position? 1 Answer