# \[SHOOTING\]Rotated towards a target

**URL:** https://forum.kirupa.com/t/shooting-rotated-towards-a-target/186615
**Category:** programming
**Created:** [April 22, 2006, 9:34pm UTC](https://forum.kirupa.com/t/shooting-rotated-towards-a-target/186615 "2006-04-22T21:34:31Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![cobrasniper555](https://avatars.discourse-cdn.com/v4/letter/c/838e76/32.png) [@cobrasniper555](https://forum.kirupa.com/u/cobrasniper555)
#### Post date: [April 22, 2006, 9:34pm UTC](https://forum.kirupa.com/t/shooting-rotated-towards-a-target/186615/1 "2006-04-22T21:34:31Z")

</div>

Hello, basicallly, is there a type of shooting to check if the gun is pointing at a target? Like, you get a target, you get the angle from the gun to the target…and, when the mouse is pressed, the gun will check to see if it is in the same angle as from the gun to the target.

---

<div class="post-metadata">

### Author: ![woad](https://avatars.discourse-cdn.com/v4/letter/w/34f0e0/32.png) [@woad](https://forum.kirupa.com/u/woad)
#### Post date: [April 23, 2006, 1:50am UTC](https://forum.kirupa.com/t/shooting-rotated-towards-a-target/186615/2 "2006-04-23T01:50:45Z")

</div>

I’m working on one of my games right now so I can’t create the code. I can explain what to do though. Find out how to rotate something towards a target. Put that into the game. And check if your angle is the same angle needed to hit the target:

if (currentRotateAngle == NeededTargetAngle)  
{  
Fireing = true;  
//says that you can now fire the gun  
}  
if (Fireing == true)  
{  
Place all the shooting stuff into here  
}

There you go… Back to work!!! :crazy: :mountie:

---

<div class="post-metadata">

### Author: ![cobrasniper555](https://avatars.discourse-cdn.com/v4/letter/c/838e76/32.png) [@cobrasniper555](https://forum.kirupa.com/u/cobrasniper555)
#### Post date: [April 23, 2006, 1:52am UTC](https://forum.kirupa.com/t/shooting-rotated-towards-a-target/186615/3 "2006-04-23T01:52:23Z")

</div>

Ok. I’ll figure something out, and then I’ll post it on here. Thanks for helping!

---

<div class="post-metadata">

### Author: ![cobrasniper555](https://avatars.discourse-cdn.com/v4/letter/c/838e76/32.png) [@cobrasniper555](https://forum.kirupa.com/u/cobrasniper555)
#### Post date: [April 24, 2006, 4:35am UTC](https://forum.kirupa.com/t/shooting-rotated-towards-a-target/186615/4 "2006-04-24T04:35:03Z")

</div>

Ok…I’ve figured out a script for if you shoot DIRECTLY at the (x,y) of the target. But what I want to do is make it so that if you just point in any general direction that you will hit the target, not just on its ordered pair. So maybe when I put in ordered pair differences, maybe I could make the ordered pair add and subtract some number(Say, it’s width, for example). This is hard…I need someone smart to help me out here, lol.
