Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [mouse]

A very common input device in computer games. It offers a more direct form of movement compared to directional input.

0
votes
1answer
12 views

Unity SceneView Positionning object with mouse position in Editor script

I would like to create an editor tool who can change the position of an object in the scene view into other object in the world, based on mouse position, like in the picture bellow (the red pyramid is ...
0
votes
1answer
57 views

Ideal 3D platformer controls for Keyboard + Mouse [closed]

I am developing a 3D platformer, and I know that controller is optimal for the precise movement, but I don't feel players should have to buy a controller just to experience a 3D platformer that is ...
0
votes
0answers
23 views

SDL_WarpMouseGlobal does not work in game

I tried to use SDL to move mouse in game. The function works fine only in menu, when I join a game, the function does not work. I checked coordinates with ...
0
votes
0answers
58 views

How to drag an object with mouse with collision?

I want to drag a GameObject with the mouse but I need collision. The basic mouse dragging code simply sets the position of the object to the hit.point with an ...
0
votes
1answer
16 views

Transfer mouse movements to a GameObject in 3D according to camera position and rotation

I'd like the game object to follow the mouse but I have trouble doing this when the object is in 3D and the camera has been rotated. The only thing that seems to be true (and still it works only when ...
0
votes
0answers
29 views

ImGui: disable window move with drag event on image

I'm displaying an image with ImGUI like this: ...
0
votes
2answers
66 views

How to panning camera on XZ axis with different angles

I have an Orthographic camera where the position is { x:0, y:100, z:0 } and is pointing/looking at { x:0, y:0, z:0 }. At this ...
0
votes
1answer
43 views

Drag object with mouse in diagonal direction

I have a gameobject which i want to move using mouse. Currently i can do that in x-axis and y-axis: ...
0
votes
1answer
79 views

Move camera while dragging with mouse

I'm currently trying to implement a move-to-drag behaviour in a 2d grid based game. I want to update the camera such that if follows the "head" of the trail being drawn - In this case, the nodes it is ...
1
vote
1answer
144 views

Drawing many separate lines using mouse OpenGL(GLFW/glad)

So, in order to draw a line, I track the coordinates of the mouse, then I add them to the array and capture it as GL_LINE_STRIP_ADJACENCY. However, for example, I completed drawing a line1 at P1 and ...
1
vote
1answer
97 views

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

I was wondering: What is the exact difference (if there is any) between a hotkey and a shortcut-key in a game? Some games for example allow the player to bind certain actions to a specific key and ...
0
votes
2answers
82 views

How can I make the cursor avoid something completely?

I wrote some code for a UI button that causes the mouse to avoid it. I realize this is kind of a weird thing to do in a game design-wise, but this is a really weird game. I need a button that is not ...
1
vote
1answer
70 views

How do I calculate a new position from current and target position for intuitive non-instant dragging?

I have a simple 2D game where I can move an object using the mouse. I've been improving on the 'feel' of the movement gradually, however it still doesn't behave as you'd expect if the object were to ...
0
votes
1answer
303 views

unity 3d mouselook script help, weird issue

I'm coming back to Unity after a year or two of busy college and I'm having to relearn everything I've forgotten. One thing I cant seem to get right is this basic mouselook script I wrote. Here is the ...
0
votes
1answer
84 views

Rotating Weapon Towards mouse.position

OK guys i have tried lots of things and researched but cannot find a solution please someone give me hope.. So on my phone when i am playing i want to shoot with a screen button in the canvas that is ...
0
votes
1answer
173 views

How to know if mouse coordinates is delta or absolute on Window and Android in Unity?

I wrote sample application, that allows to "rotate" object by mouse. Rotation occured by rotating of camera object around central object and the code is following: ...
0
votes
0answers
21 views

Mouse: Intelligent Focus Helper

h.e.l.l.o I tried to get a kind of focus helper with the mouse when the pointer rolls over an item. but i can get a good easing when the mouse are hover a element. I do not know if I explain myself ...
0
votes
1answer
48 views

Detect if mouse do multiple circle rotation around a XY point

would anyone know a method or algorithm (js) to calculate and detect if a mouse is moving by a circle around a target? Example if a rotate mouse *4 time around a specific XY point, i would like to re-...
-1
votes
1answer
55 views

Having trouble making more than 1 clickable object

I am a student trying to figure out how to make multiple clickable objects in pygame. I was able to make 1 working clickable object (dx,dy) work, but when I tried to make another clickable object (qx,...
1
vote
2answers
103 views

How do I convert OnCollisionEnter2D to OnMouseDown?

I created a simple animation. I have a "Gamer" object, which I move and hit squares to destroy them. Squares I have to destroy in the right order ...
0
votes
1answer
97 views

Why does the object not move correctly when I press the right mouse button?

2D Game in UNITY C# I have an object BULLET . After pressing the left mouse on my object (BULLET), the script allows me to rotate object according to the mouse's direction, in four directions : -...
0
votes
2answers
56 views

How to keep clicks from menu from interfering with game state?

I ran into a problem coding my game in which when I click the play button on the newly implemented menu, it also creates a bullet from my player. The player and the menu both rely on the mouse input. ...
1
vote
1answer
34 views

Mouse position not updating while mouse buttons are pressed

I have a simple mouse manager class: https://imgur.com/MuUhh73 Whenever any of the mouse buttons are pressed the mouse position does not update when calling ...
-1
votes
1answer
19 views

Help me understand the numbering of buttons in GetMouseButtonDown

I'd like to know what the "0" stands for in this code: if (Input.GetMouseButtonDown (0)) // Do something here
0
votes
1answer
261 views

Trying to get an object to move in the mouse direction XNA C#

Right, so in my Player class where I call the object I got an if statement which gets the coordinates for the mouse ...
0
votes
1answer
179 views

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

This question came from some of my students. I wanted to share it here so others can find & improve on the solutions we've found so far. In particular, my answer below doesn't behave as well as I'...
0
votes
1answer
178 views

2D Screen Coordinates to 2D World Coordinates in LWJGL

I'm making a 2d top down game with lwjgl and am having trouble converting my 2d screen coordinates to 2d world coordinates. Here's what I have so far ...
1
vote
0answers
230 views

Is there a way to get mouse coordinates relative to an sfml window without locking the mouse to the window border or monitor edges?

As the title states, is there a way to get the relative mouse coordinates to the sf::RenderWindow without locking the mouse cursor inside of the window border or monitor edges? In glfw using a mouse ...
1
vote
1answer
220 views

SDL2 dragging a sprite with mouse

I am trying to figure out how to drag a sprite. I know when the mouse is being hovered, pressed, or released over a sprite. I don't know how to tell if the mouse is being pressed and moved at the same ...
1
vote
1answer
169 views

How can I process extra mouse buttons using Monogame?

I use Monogame for game development. For processing mouse input, I can use the Mouse class to query basic information like left click state, right click state, and ...
3
votes
1answer
137 views

Compare mouse movement to the pattern

There are some games where you need to make special movement with your mouse (spell casting or any other action). Something like this So basically, how can I compare mouse movement to my pattern (...
0
votes
0answers
51 views

How to abstract mouse movement event streams for networked multiplayer?

I'm building a mouse driven 3rd person shooter with client-server network architecture. My input system is event based. Keyboard input is captured by keys.S.onUp() ...
1
vote
1answer
111 views

How can I calculate respective 2D world/mouse position through different resolutions?

I have been at this game of trial-and-error for days now. I cannot find a consistent method to calculate the respective mouse position in my game world after the calculations are done to stretch the ...
2
votes
1answer
266 views

How does mouse input work in 3d games? [closed]

How does a game process cursor movements? I know it calculates offset from the middle of the screen, but how? What constraints is that cursor having? Is it locked to the middle of the screen/a ...
5
votes
1answer
68 views

How can I use more than one mouse connected to the same computer as different input devices in Unity?

How can I use more than one mouse connected to the same computer as different input devices in Unity? I want to read the input axis of each mouse individually for local multiplayer games.
12
votes
2answers
2k views

How to make a delayed mouse input?

I have a car game and the idea is that the player is drunk. I want to have a delayed input from the mouse, where you move the mouse side to side to turn. How can I setup a constant delay between the ...
0
votes
1answer
222 views

Drawing Sprites Depending On Mouse Position (LibGDX)

I'm making a small game where you play as a turret in the middle of the screen trying to shoot the enemies coming after you. I am having difficulties, however, in trying to figure out how to make the ...
0
votes
2answers
882 views

Touch a specific area on the screen in Unity 5

I am building a Roulette game in Unity 5. I want to place bets on a Roulette table when I touch specific areas on the screen with mouse(PC) and touch(mobile). For example when i touch Number 1 on the ...
1
vote
1answer
85 views

How can I make part of a JLabel visible under mouse movement?

The JLabel has an image of a room. I want the mouse to act as a flashlight, and only display around the mouse the part of the JLabel/image that the mouse is hovering over, in a large circumference. ...
2
votes
0answers
332 views

Why is my 2D mouse aim not working properly?

I'm trying to program 2D mouse aim, where the arms and the gun in the arms rotates to point at the mouse. But for some reason, the arms and gun rotate and do not follow the mouse position. The each ...
1
vote
1answer
30 views

Reversing translational dependency of Sprite on Mouse instantaneously at runtime without causing the sprite to jump

Help me think through a logical way to implement the desired effect. Goal: (I'm using Adobe Animate CC 2017 targeting AIR for Desktop) Move a sprite using a controller (mouse on a PC for instance) ...
3
votes
3answers
3k views
0
votes
1answer
39 views

How to check mouse coordinates and mouse events

I'm building a simple game where if the mouse's X coordinate is greater than 200, and you click, the screen will turn red. Here's the code: var mouseX = event.clientX; var mouseY = event.clientY; ...
0
votes
3answers
2k views

Detecting mouse click for the uppermost layered 2d sprite in Unity

I have two sprites. One for the entire background and another small sprite, which is a foreground object. I have written code for both of these objects in their ...
0
votes
1answer
18 views

Wrong object is being detected on OnMouseUpAsButton

In my 2d game project I have an object A moving above map. Both object and map have colliders (circle collider and polygon collider respectively), as well as actions to be performed on ...
0
votes
1answer
261 views

Unlock cursor through script

I am using unity's default FPS controller script. My game switches scenes, and when it does I can't move the mouse. I know that this is because of unity's m_mouselook's lock cursor is on. What I don't ...
-1
votes
1answer
489 views

Missing Reference: Unity should clone object before destroying

For a small RTS Project, I'm working on the pointer. I want a pyramid as a marker on the terrain, that indicates the selected position, sinks into the ground and disappears. For the next interaction ...
1
vote
1answer
723 views

Custom Unity mouse input with WM_INPUT - receiving weird values

About I am trying to get the raw mouse input of the system into a C# application. I am using WM_INPUT (MSDN link) to get access to the data. To do so I am using ...
0
votes
1answer
110 views

Why is my mouse disappearing at runtime?

I'm using Unity 5.3.5f1 and every time I play my game in the editor, my mouse disappears. I really need to test some of my parameters in the inspector but I can't because the mouse is gone. How can I ...
1
vote
2answers
6k views

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

I can detect if mouse is hovering any UI element by EventSystem.current.IsPointerOverGameObject(). But how do I know which ...