31 votes

How to make a delayed mouse input?

To simulate a time lag, use a circular buffer to store the last N frames' mouse positions. Store the current mouse position each frame. In your control calculations, use the oldest mouse position from ...
Buster's user avatar
  • 401
13 votes
Accepted

How to properly differentiate single-clicks and double-click in Unity3D using C#?

Coroutines are fun: ...
CostelloNicho's user avatar
8 votes

How can I make the player "look" to the mouse direction? (Pygame / 2D)

First you need to calculate the vector pointing from your player to the current mouse position. This can be done by subtracting the player's position with the mouse's position: ...
Ted Klein Bergman's user avatar
5 votes

How to properly differentiate single-clicks and double-click in Unity3D using C#?

I can't read English. But UniRx may be able to help you. https://github.com/neuecc/UniRx#introduction ...
user2971260's user avatar
4 votes
Accepted

Setting up a custom cursor image in LWJGL 3

...
xoric's user avatar
  • 175
4 votes
Accepted

How to make a delayed mouse input?

I ended up using a coroutine, because (from what I understand) the delay will be constant regardless of the performance of the device running the game. This is my code: ...
mr-matt's user avatar
  • 2,759
4 votes
Accepted

Compare mouse movement to the pattern

I think the best way to solve this is by using a neural network that has been trained extensively on a lot of data. Draw your own shapes, make your friends draw them etc. It would then be able to ...
Racksay's user avatar
  • 56
4 votes
Accepted

What's causing this stutter when framerate fluctuates?

You're averaging the total travel of the mouse on a frame. The travel of the mouse is proportional to the speed the player is moving the mouse and the duration over which you measure the movement. ...
DMGregory's user avatar
  • 134k
4 votes

Triggering Enhanced Input Actions via inputs with modifier keys (Shift/Alt/Ctrl) in UE5

After doing some more research and implementing a solution that does work for me, I feel confident to be able to answer my own question. Unfortunately, the answer is: It's as cumbersome as already ...
Simon Fischer's user avatar
3 votes

How can I get UI element over which pointer is in Unity3D?

Unity 4.6 UI doesn't really like those OnMouse events, so we can't use OnMouseOver() for example. (Those are just for Colliders or GUIElements.) Instead, we use Pointer properties from Selectable ...
Zael's user avatar
  • 131
3 votes
Accepted

How to get which gameobject the mouse is over in Unity?

Physics.Raycast will help you to get the gameobject using mousePosition and ScreenPointToRay ...
Muhammad Faizan Khan's user avatar
3 votes

Sending a players mouse movement to the server in an FPS

Translate mouse input to rotation on the client-side. Then send the new view direction to the server, not raw mouse input. Usually there is more than one way to change the players view direction (...
Philipp's user avatar
  • 119k
3 votes
Accepted

SDL2 dragging a sprite with mouse

"Pressed" and "Released" are usually treated as events, rather than states. (ie. "Became Pressed" rather than "Is Still Pressed") So processing a drag can be as simple as: When the Pressed event ...
DMGregory's user avatar
  • 134k
3 votes

How can I attract & repel the mouse cursor from particular UI controls?

We can take complete control of how Unity handles cursor events by providing our own InputModule. Start by finding the EventSystem in your scene, and removing any existing InputModules from it, and ...
DMGregory's user avatar
  • 134k
3 votes
Accepted

What is the difference between a hotkey and a shortcut-key in a game?

With "Shortcut", there is the implication that there is a more intuitive but also more elaborate way to perform the action (like navigating through a menu). "Hotkey" is a more general term which can ...
Philipp's user avatar
  • 119k
3 votes

Unity Round (Circle) Buttons

This is much simpler than it seems. Unity has functionality built in for this. theButton.alphaHitTestMinimumThreshold = 0.5f; Documentation What this does is ...
Evorlor's user avatar
  • 5,793
3 votes
Accepted

Can Event Triggers be used on Non-UI objects?

You can do this if you add a Physics Raycaster component to your camera. Just make sure you have colliders on the same GameObjects that have the EventTriggers you want to be clickable. You also have ...
Ed Marty's user avatar
  • 5,229
3 votes
Accepted

Best Practices for Locating Clicks

As with every problem, there are many ways to come to a solution. But one solution I usually find the easiest to implement is: Add an EventSystem to your scene. Which happens automatically when you ...
Philipp's user avatar
  • 119k
3 votes
Accepted

How to see which mouse button was pressed (Unity Input System)

You don't. The InputActions assets in the new input system are meant to create an abstraction layer between different pieces of input hardware and what actions ...
Philipp's user avatar
  • 119k
3 votes

How do I make a 3D cursor that follows the mouse in Godot?

Camera3D.project_position is the Godot equivalent function. Here's an implementation that can either move the position with fixed orientation or can also point the ...
idbrii's user avatar
  • 798
2 votes

Is it possible to detect two different mice at the same time, and have their movements recorded separately?

Looks like it can be done using calls to user32.dll to the GetRawInput* methods. There is an example of how to do this in rawinput-sharp. I apologize for the link-...
HackSlash's user avatar
  • 121
2 votes

How to properly differentiate single-clicks and double-click in Unity3D using C#?

I was looking for a proper single-double click handler. I've found this topic and gathered some really good ideas. So finally I've came up with the following solution and I want to share it with you. ...
Norb's user avatar
  • 21
2 votes

How to properly differentiate single-clicks and double-click in Unity3D using C#?

The above solutions work for clicks done on the whole screen. If you want to detect double-clicks on individual buttons, I've found this modification to an above answer is working well: ...
zavtra's user avatar
  • 121
2 votes

How to properly differentiate single-clicks and double-click in Unity3D using C#?

Windows default double click delay is 500ms = 0.5 seconds. Generally in a game it's much easier to handle double click on the control that's being clicked, not globally. If you decide to handle ...
Peter's user avatar
  • 9,925
2 votes

OnMouseClick not detected

problem actually was that I typed onMouseDown() instead of OnMouseDown() .. Everybody coming from Java world pay attention!!! MonoDevelop will not warn you that mathod with such a name doesn't exist, ...
Ewoks's user avatar
  • 131
2 votes
Accepted

Make object follow mouse cursor in unity

This is the signature of the function you're trying to use Vector3.Project(Vector3 vector, Vector3 onNormal) you're passing it only 1 parameter. And this is the ...
Leggy7's user avatar
  • 1,454
2 votes
Accepted

In Unity, Change which mouse button is used to scroll in ScrollRect

Grab the UI source from bitbucket. Default input should be changed by changing those left mouse button input. Or you may override those methods.
Sourav Paul Roman's user avatar
2 votes
Accepted

Calculate Relative Mouse Movements Regardless of position

If you want to find out the mouse position, even if the mouse is outside of the window, you can use the MouseInfo class of AWT: ...
Hunter99's user avatar
2 votes
Accepted

Help me understand the numbering of buttons in GetMouseButtonDown

When you have questions about how part of the built-in Unity API works, the best place to start is the Unity documentation. On the page for Input.GetMouseButtonDown you'll find this: ...
DMGregory's user avatar
  • 134k
2 votes
Accepted

Mouse position not updating while mouse buttons are pressed

The problem is with your implementation. Change your button handling code to something like : ...
Ian Young's user avatar
  • 2,649

Only top scored, non community-wiki answers of a minimum length are eligible