Get Mouse Click Position

Just began to try the new input system.

I want to configure the ActionMap as having tap (when on touchscreen) and mouse click (when on pc) have the same effect to return the position where the user taps/clicks. And I expect that in the callback body I can focus on only the position it returned, just like:

 public void OnMove(InputValue value)
    {
        Debug.Log(value.Get<Vector2>());
    }

However, so far I still find no way to properly configure the ActionMap to achieve this. The closest way is to check whether the left mouse button is clicked in the callback body. But this way seems not so ideal as it breaks the abstraction and encapsulation, which are the design objectives of the new input system.

Could someone please give me some suggestions?

Thanks.

1 Like

I tried for hours and was not able to do this. Gave up with great frustration. It’s either a click, or position.

Ended up using “Press [Pointer]” binding just to trigger the event, and in the callback I looked at Pointer.current.position …

It’s so sad that such a basic thing is so counter-intuitive to achieve in the new system.

I hope someone steps in to explain how to do this.

I’d use polling for this aswell. Get a reference to a Mouse (or pointer) position, and in your “click” callback get the value of the position action.

I have the same concern and was working my way through the demo/sample project to try and figure it out.

I’ve attached a screenshot from the demo/samples provided with the new input system, which shows what looks like a fifth composite binding: “Pointer Input”.

I’ve tried just about every combination of control scheme/action type and property and still can’t find this binding. Could someone please help a newbie out?

I think that is their custom written composite, which is some kind of a custom combination of data. I gave up right there, hoping that for sure they would not require us to write custom composites for such a basic thing. But it very well may be that this is the case:/