vectorToAngle issues
jonmulcahy
Member, Sous Chef Posts: 10,408
Is it possible to get an angle between two points, but relative to the actor not the scene? I've got a little guy, and i want him to be able to shoot upwards, but only 15 degrees from the top on each side.
the gameplay will be, touch to shoot to that position, if the angle between the guy and the destination is in the allowable area, shoot, otherwise do nothing.
if the guy is standing flat on the ground, this is easy, I can get the vector to angle of his position and the x position, and if that value is between 75 and 105, shoot. But my guy won't always be straight on the ground, he's rotating around a circle, so his base angle needs to adjust.
I tried using the rotation value to keep it calibrated, but that value keeps increasing the more the player rotates around the circle.
any ideas?
the gameplay will be, touch to shoot to that position, if the angle between the guy and the destination is in the allowable area, shoot, otherwise do nothing.
if the guy is standing flat on the ground, this is easy, I can get the vector to angle of his position and the x position, and if that value is between 75 and 105, shoot. But my guy won't always be straight on the ground, he's rotating around a circle, so his base angle needs to adjust.
I tried using the rotation value to keep it calibrated, but that value keeps increasing the more the player rotates around the circle.
any ideas?
Comments
i think that might work, it's at least got me moving in the right direction. thanks!
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
Hm... Web Developer...
http://gendaigames.com/careers/#job-wd
time to go through the demos!
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
I've got a turret. it's only allowed to shoot +15 / -15 degrees from it's center point, but the entire thing could be pointing in any direction.
Looking at the diagram below, I if I take a vector to angle of the center point to the valid target point (red), it'll come back something like 60 degrees, because it's based on 0 being "EAST" and 90 being "NORTH". I want the yellow line to be the "0, and the red lines to be +15 and -15 (or 345, whatever it has to be)
but I may have 2 turrents pointing at different directions, so it has to be modular.
can anyone help
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
when you know the red and yellow dots X and Y coordinates?
If you want to restrict the movement of the turret, then min/max might be a better way to go.
The Pythagorean Theorem / vectorToAngle uses right angles. In your images, I don't see the use of right angles.
@Photics,
not really, it's just the best way to describe what I want, each turret would be almost static, it could only move within the red lines, but the circle itself will never move.
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
constrain self.angle to: (vectorToAngle(( game.X - self.Position.X ),( game.Y - self.Position.Y ))) - self.rotation
game.X. and game.Y are the red dots location, self.pos.X/Y are the turrets location.
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
Both are constrain, the top one is self.angle2 and the bottom is the angle I highlighted in the image above.
thank you so much
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left