- Home /
Mouse click in different positions in screen and game view. Screen view is what is actually detecting, how do I fix this?
Expected behavior: When I click at a position on the screen, a circle of growing radius forms there and it grows until it reaches a target radius. All floating textmeshes whose colliders collide with the circular sprites collider should instantly stop moving.
Issue: The collision is not detected because where the click appears in my game view is not where it actually happens which I noticed when I saw the circle form in a different position in the scene view. I cant figure out why the circles are forming in different positions in scene and game view.
On the right is the game view where you see the ciricle is much larger and its center is where I clicked in the game view, somewhere near the last e.
But in the scene view the circle is so small and it is so off from where I actually clicked.
This is causing the wrong textmesh to be passed to my trigger. Each of the letters are individual textmeshes that have scripts that make them float around.
The Inspector shows my main cameras components which I suspect is the issue, could be the pixel perfect camera maybe?
In my code this is the part that handles where the mouse is clicked in the game view:
if (Input.GetMouseButtonDown(1) && !wave && timerWhenWaveAbsent >= shockwaveCooldown)
{
//Get Mouse Pos
Vector3 mousePos = Input.mousePosition;
mousePos.z = 10;
mousePos = Camera.main.ScreenToWorldPoint(mousePos);
//Spawn the Shockwave
wave = Instantiate(shockwavePrefab, mousePos, Quaternion.identity);
timerWhenWaveAbsent = 0;
}
Been at it for hours, please help me :(
Your answer
Follow this Question
Related Questions
Sprite Not Displaying In-game 0 Answers
Camera.ScreenToWorldPoint with Perspective camera 1 Answer
ScreenToWorldPoint not working 1 Answer
Understanding smoothTime in Mathf.SmoothDamp 0 Answers
Project an object from a perspective camera at same screen position but different Y world position 0 Answers