Can anyone teach me how to perform a 2d mouse aiming on v4.3?
1 Answer
1You have to get world coordinates from the screen coordinates of the mouse. This is done using the camera.
Vector2 characterPosition;
Vector3 3DmousePosition = camera.ViewportToWorldPoint(Input.mousePosition);
Vector2 2DmousePosition = new Vector2(3DmousePosition.x, 3DmousePosition.y);
Vector2 directionFromPlayerToMouse = (2DmousePosition - characterPosition).normalize;
What do you mean by aiming? - Select objects under the cursor? - Spawn objects under the cursor? - Move the camera with the cursor? - ...?
– Spinnernicholasan AIM pointer like in the METAL SLUG Series. The only problem is that when I try to shoot, the rocket is not on the location as the mouse pointer.
– jvt619