Search Unity

Question How to get mouse position in Visual Scripting with the New Input System

Discussion in 'Visual Scripting' started by Manu_Hu, May 31, 2022.

  1. Manu_Hu

    Manu_Hu

    Joined:
    Sep 13, 2017
    Posts:
    6
    Hey folks,
    i was trying to get the current mouse position with the new Input System and Visual Scripting. Though i didn't find any node for that purpose, only the three "On Input System Events". Can someone point me in the right direction pls. ?

    Thanks in advance.

    Cheers,
    Manu
     
    MistyPine likes this.
  2. MistyPine

    MistyPine

    Joined:
    Dec 16, 2020
    Posts:
    10
    Same problem
     
  3. Manu_Hu

    Manu_Hu

    Joined:
    Sep 13, 2017
    Posts:
    6
    If ound a solution. In the mapping switch the mouse binding from delta to Position. That worked for me, at least :)
     
  4. Manu_Hu

    Manu_Hu

    Joined:
    Sep 13, 2017
    Posts:
    6
    read above ^^
     
  5. MistyPine

    MistyPine

    Joined:
    Dec 16, 2020
    Posts:
    10
    can you tell me the name of the function you have?
    it is already position but in my case I need the mouse position when the left click is pressed
    upload_2022-7-11_17-6-37.png
     
  6. Manu_Hu

    Manu_Hu

    Joined:
    Sep 13, 2017
    Posts:
    6
    Hm, i have the same set-up, except i read the value all the time. Maybe it works for you, if you go to interactions and add "pressed".
     
  7. MistyPine

    MistyPine

    Joined:
    Dec 16, 2020
    Posts:
    10
    I tried and it doesn't work, I don't understand how a position could be pressed, and how the interaction could know if it is left or right click.
    Can you show me how do you get the position in your case please? I don't see how with both new input system and visual scripting
     
  8. Manu_Hu

    Manu_Hu

    Joined:
    Sep 13, 2017
    Posts:
    6
    Sorry, been a bit busy. Here's what i had (switched the system completely, didn't fit my needs anymore).
     
  9. Manu_Hu

    Manu_Hu

    Joined:
    Sep 13, 2017
    Posts:
    6
    Don't know why my images always break.... Did you convert the Input value from Screen Position to World Position ?
     

    Attached Files:

  10. brian1gramm1

    brian1gramm1

    Joined:
    Sep 15, 2017
    Posts:
    56
    I seriously dislike the new input system for this reason
     
  11. unity_0hWW885bnk03Dg

    unity_0hWW885bnk03Dg

    Joined:
    Nov 28, 2021
    Posts:
    5
    in the input window make a new action of pointer position and you have to add the input system library to your visualScripting in the project settings then once you have the input system library installed and regenerated go to your script and add a on inputSystemVector2 or something like that i forgot the exact name but you should be able to find it with that or just go with vector 2 and scroll a little then once you have the node in the dropdown pick the event that you had just made and the vector output is the position of your cursor or pointer i havent found the difference yet. And do remember that this position is relative to your screen so 0,0 is at the bottom left if you want to get the wold space postion then get a canvas to world space node put in your camera and the position of the cursor and you have the world space. good luck and i hope this helps