Questions tagged [aiming]

Taking focus on a target, often to shoot it, and even more often in the head.

Filter by
Sorted by
Tagged with
37 votes
1 answer
7k views

Mouse aim in an FPS

I would like to make a First Person Shooter and move the camera with the mouse. The problem is that when the cursor reaches the limits of the screen, the camera won't turn anymore. How can I keep the ...
BlackBear's user avatar
  • 506
26 votes
5 answers
8k views

Target Tracking: When to accelerate and decelerate a rotating turret?

Say I have a moving circular target defined as: Vector2 position; Vector2 velocity; float radius; And a rotating ...
Andrew Russell's user avatar
14 votes
2 answers
17k views

How to calculate shot angle and velocity to hit a moving target?

I am developing a 2D Android game and I am making an aiming algorithm for AI projectiles to hit enemies either following a path, or free moving. At the moment it just calculates where the target will ...
Guen's user avatar
  • 141
14 votes
2 answers
10k views

Predicting enemy position in order to have an object lead its target

In my 2D game I have AI turrets that should assist the player by automatically firing towards enemies. I would like to make them fire intelligently and lead their target instead of just targeting an ...
Kryptic's user avatar
  • 315
13 votes
5 answers
7k views

How can I launch a GameObject at a target if I am given everything except for its launch angle?

I am trying to launch an object at a target, given its position, its target position, the launch speed, and the gravity. I am following this formula from Wikipedia: $$ \theta = arctan \bigg( \frac{v^...
Evorlor's user avatar
  • 5,793
12 votes
5 answers
5k views

What makes aiming in a console first person shooter feel good?

I think it's pretty much universally agreed that simply mapping the analog stick to rotational speed of the character is not good enough to make console first person shooter feel good. So what are ...
Tetrad's user avatar
  • 30.1k
12 votes
2 answers
6k views

Algorithm to shoot at a target in a 3d game

For those of you remembering Descent Freespace it had a nice feature to help you aim at the enemy when shooting non-homing missiles or lasers: it showed a crosshair in front of the ship you chased ...
Sebastian Bugiu's user avatar
10 votes
4 answers
1k views

Calculating missile trajectory around orbits before shooting

I'm building a game with Unity3D. It's a Gravity Wars clone. Both player and AI turrets shoot missiles at each other (giving an Angle and a Power variables), trying not to crash missiles on planets. ...
Onofrio's user avatar
  • 101
9 votes
5 answers
8k views

How to lead a moving target from a moving shooter

I saw this question: Predicting enemy position in order to have an object lead its target. My situation is a little different though. My target moves, and the shooter moves. Also, the shooter's ...
Azaral's user avatar
  • 376
9 votes
1 answer
478 views

Targeting a vehicle with complex movement?

Targeting a vehicle with known constant velocity is simple, and collision is guaranteed (see Predicting enemy position in order to have an object lead its target, Find meeting point of 2 objects in 2D,...
e100's user avatar
  • 319
6 votes
1 answer
7k views

How do I determine a good path for 2D artillery projectiles?

I'm building a little "tank wars" game (like this one). I understand the math, and I am able to define a parabola from the launcher to the objective I want to reach. The parabola depends on the ...
Notbad's user avatar
  • 1,095
6 votes
4 answers
2k views

How can I draw a sprite that inverts the colors behind it for an aiming reticle?

In XNA, how can I draw a sprite on the screen that inverts the colors behind that sprite (i.e. the colors that would appear if the sprite weren't in the way of them)? I feel this is the best ...
Corey Ogburn's user avatar
  • 1,125
5 votes
2 answers
7k views

Projectile Aim Prediction with Acceleration

I'm trying to solve the classic shoot moving object problem but with acceleration attached to that changes it from a quadratic to quartic formula but my math skills are not this good sadly as i prefer ...
HellGate's user avatar
  • 103
5 votes
2 answers
924 views

What makes aiming on a PC first person shooter feel good?

I liked this question: What makes aiming in a console first person shooter feel good? So here it is for PC (and its not a dupe because a mouse is hugely different from an analog stick) You've ...
Pyrolistical's user avatar
4 votes
3 answers
4k views

Given an angle for an arrow, how do I find its X and Y velocities?

I want to fire an arrow toward the mouse location. X0 = the players X location X1 = the mouse X location Y0 = the players Y location Y1 = the mouse Y location I ...
Amit Assaraf's user avatar
4 votes
1 answer
5k views

How do I make a 2D character aim their gun toward the mouse?

Heli Attack is a perfect example of the shooting mechanic I'd like. The character aims perpetually toward the mouse. What's going on here? From what I've read so far, you could separate the arm and ...
atkayla's user avatar
  • 221
4 votes
2 answers
2k views

Is this aiming mechanic usable in a third-person top-down game?

Long story short: I've switched to a third person - top down perspective. The camera is fixed and looks down at the player. How can I implement 3d aiming ? The player needs to aim left and right as ...
lhk's user avatar
  • 408
3 votes
3 answers
2k views

Calculating 2D Physics Prediction of Shot Angle with Moving Velocity of both targets

I currently have the math right to hit a moving target with 99% accuracy as long as I don't move. When I start moving the aim is nearly 80%, it should also be 99% accuracy because the target is moving ...
SSpoke's user avatar
  • 133
3 votes
1 answer
311 views

Determine if an object is inside a ship's turn radius, rotation via torque

I have a 3d space game where all ships move around using physics. I am trying to determine if a given object is reachable by a ship at a given velocity and turn radius. I believe the formula for turn ...
weichsem's user avatar
  • 515
3 votes
1 answer
4k views

Aim prediction along a parabola - How to make a Tower Defence Mortar aim accurately

I am building a very basic tower defence game in Unity3D where one tower is your standard long range mortar/artillery. I want the projectile it fires to follow a parabola curve to make its movement ...
Tom 'Blue' Piddock's user avatar
3 votes
0 answers
448 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 ...
Grigori's user avatar
  • 51
2 votes
1 answer
809 views

Rotate object such that a child object is facing a target (3D)

Given a parent object A and a child object B, how do I find the rotation of A such that B is pointing toward the position of a target C. This is a simplified way of solving 'what angle does the torso ...
Rotem's user avatar
  • 205
2 votes
1 answer
774 views

How do Aimbots get detected?

I was wondering on the programming methods which are used to detect when a player is using an Aimbot/AutoAim cheat.
Edoardo99's user avatar
2 votes
1 answer
2k views

One to one aiming in 2D platformer

Hello all I have been having an issue with a 2D platformer I'm working on in Unity. It has an aiming style similar to Shadow Complex where the aiming will rotate around the character in direction to ...
Brad Whitefield's user avatar
2 votes
0 answers
272 views

How can I use iteration to lead targets?

In my 2D game, I have stationary AI turrets firing constant speed bullets at moving targets. So far I have used a quadratic solver technique to calculate where the turret should aim in advance of the ...
e100's user avatar
  • 319
1 vote
1 answer
737 views

Moving turret aiming at moving target

I've found this post Turret Aiming Formula on Reddit and a nice answer a while back. The solution in the answer works great for still sanding turrets but is almost unusable for moving turrets since ...
Roman K's user avatar
  • 123
1 vote
1 answer
139 views

How to clamp a mouse angle within a field of view range of the facing direction

In my top down shooter game, the player can face in any of the 8 compass directions using the keyboard. Depending on the direction, the player will have a 90 degree field of view to turn based on the ...
Hasen's user avatar
  • 194
1 vote
2 answers
991 views

How do I launch a ballistic projectile to hit a moving target, given: launch position & angle, target position & velocity?

This problem is in 3D space. My question is: How do you find the initial velocity of a projectile that flies under constant gravity, so that it hits a target moving with constant velocity, given the ...
JPSmithpg's user avatar
1 vote
1 answer
2k views

Aim assist (GoldenEye/Perfect Dark)

Anyone remember how the aim assist works in GoldenEye on n64? Where the gun model would point at an enemy if he's within a certain area in your field of view. I'm trying to do something like that but ...
herewego's user avatar
1 vote
3 answers
638 views

Targeting with a ballistic gun

I am trying to determine the gun elevation angle of a gun that fires ballistic projectiles. For a target at a certain distance D, I will have to compute an angle that increases with D. This relation ...
Bram's user avatar
  • 3,729
1 vote
1 answer
118 views

Efficiently detect shoot direction with gravity playing a role?

How could I efficiently calculate shoot direction for enemy AI in order for it to hit the player? Things I know: player position, player velocity, gravity, bullet spawn position, bullet initial ...
Gintas_'s user avatar
  • 467
1 vote
0 answers
148 views

How to calculate rotations for an object with scaling transformations?

I am working on implementing scaling transformations into a game engine (C++), which previously assumed only translations and rotations. Visually, the scaling works, but a lot of the game logic ...
yah_nosh's user avatar
1 vote
1 answer
708 views

How to calculate the ideal hit of arrow? [closed]

I am trying to make the AI shoot an arrow and always hit the target. Assuming that the target is within his range I am stuck what the correct way is to do this. I search and found some solutions but ...
Marcel's user avatar
  • 11
0 votes
1 answer
1k views

Shooting the closest enemy that you can see

I'm trying to make my main character aim at the closest enemy that he can see. My issue is with the close range criterion taking priority. If the enemy is near the player but the player can't see him,...
Omer's user avatar
  • 214
0 votes
2 answers
293 views

How to get a turret to shoot at player in a shmup

I'm developing a basic vertical shoot em up on the DS and am trying to get stationary turrets to shoot at the player in a shoot em up. Early on I simply had them shooting in fixed 8 directions N, S, E ...
Skywarp's user avatar
  • 123
0 votes
1 answer
173 views

How can I implement an aiming system like the Tank Stars mobile game?

I have been trying to implement the same aiming system as in Tank Stars, but I got a little stuck. I implemented simple stick aiming, which basically aims towards the stick movement. In Tank Stars, ...
Raguel's user avatar
  • 103
0 votes
1 answer
4k views

Aim at moving target (or predicting target's position at time it takes for projectile to hit it) [duplicate]

I have a game where I know the location and velocity of my target. I know my own location and the speed of my projectile. I want to determine either the location of the intersection between my ...
allanmb's user avatar
  • 103
0 votes
1 answer
173 views

2D turret aiming at the player, but only within a certain arc and with a defined angular velocity

I have a turret game object and a player game object, say it's a spaceship. Right now, every frame the turret updates its rotation, so it's always pointing at the player, giving it potentially ...
Christian Finke's user avatar
0 votes
2 answers
274 views

2D - How to make a gun muzzle aim at the mouse when the rotation pivot isn't on the muzzle?

I'm making a simple 2D shooter game in pygame and I've come across an issue when making the character aim its gun at the mouse. To make the gun aim up and down, I've set it so that the gun uses the ...
jaregax432-awinceo's user avatar
0 votes
2 answers
5k views

Aiming direction using mouse

I'm using the following code to rotate my object using mouse, for aiming direction. The only problem with this is that it only rotates between 0 to 180 and not full 360 degrees. Can any help me locate ...
dotNET's user avatar
  • 155
0 votes
2 answers
2k views

Calculating pitch angle to hit a target using a projectile that has fixed speed

I am trying to calculate a vertical angle needed to hit a target at [distance, elevation] 2D coordinates relative to shooter given a fixed projectile velocity, air ...
Tomáš Zato's user avatar
0 votes
1 answer
744 views

Movement / aiming algorithm in 2d / tiled based game

I'm trying to create simple 2D / tiled base game in JavaScript. Entities are able to move by any number of pixels, but only in one direction at once (can't go in diagonal way). AI for enemies is ...
Setthase's user avatar
  • 103
0 votes
0 answers
26 views

Rotate the parent object so that the child object points to the cursor 2D [duplicate]

I have an arm that has a pivot point on it. I want to rotate the arm so that the barrel of the gun points to the cursor. How do I calculate the angle of rotation for the arm? I'm not very good at math ...
Haslin's user avatar
  • 1
0 votes
1 answer
559 views

Intercept an accelerating object with a constant velocity projectile

I want to calculate the time that it takes to intercept a moving target "plane" with a projectile. For example I have two 3 dimensional vectors (2 locations in 3D space). ...
nexo sharp's user avatar
0 votes
1 answer
147 views

Find vertical angle between two objects

I'm working on a project that involves a battleship with multiple turrets on it. The turrets have limited movement on both horizontal and vertical axis. When checking if they can target the player I ...
Dave's user avatar
  • 31
0 votes
1 answer
108 views

Rotating player around planet causes drift in gun aiming at mouse

I have a bug with the rotation of a gun object that follows the mouse position. It has issues when the parent object player rotates. Example: The player has a gravity script to keep them aligned with ...
koschei_dev's user avatar
0 votes
1 answer
192 views

LibGDX How to adjust mouse aim angle calculation when screen is resized

I'm starting with a screen resolution of 1280 x 960 and that is the default resolution where mouse aiming is calculated thus: ...
Hasen's user avatar
  • 194
0 votes
0 answers
93 views

Leading a target with edge casting

I am trying to write a movement prediction code. I have found the quadratic method with these topics: [1]: How to calculate shot angle and velocity to hit a moving target? [2]: http://...
Dicaste's user avatar
0 votes
0 answers
144 views

Algorithm for 2d AI aiming to compensate for gravity [duplicate]

In a 2d side-view scenario I have two riflemen aiming at each other. By normalizing the x and y difference they know the direct path to the enemy. However, gravity will pull the projectiles downwards,...
Jarmund's user avatar
  • 177
-1 votes
1 answer
84 views

Run n' Gun game: Fixating the gun's angle

I am trying to have the gun stick to facing the left or right when the player isn't pressing any of the arrow keys. For instance, if the player is aiming diagonally up-left, then when the player lets ...
Gameboy The Collector's user avatar