P
Paul Simpson
Guest
Hi,
Just a quick question. I'm trying to make a top down shooter in which the player can only shoot in the direction he is facing. I can clamp the gun objects direction to the players angle no problem, but how do I clamp towards the right 180 degrees of the screen? if the player is looking towards the right (angle 0 degrees), the gun should rotate between 270 degrees (down) and 90 degrees (up) but the following doesn't work
Putting the clamp the other way around, 90 and 270, results in the gun object being clamped towards the left, which is what I want when the player object is facing left, but not when facing right.
What numbers should I put in? I tried having the clamp to be 270 and 450, which also doesn't work. I also tried two clamps depending on where the mouse is, one from 270 to 360, the other from 0 to 90, but I couldn't get that to work either.
Please help!
edit: I just tried having the clamp be between -90 and 90 to see if that would work, but no luck.
Just a quick question. I'm trying to make a top down shooter in which the player can only shoot in the direction he is facing. I can clamp the gun objects direction to the players angle no problem, but how do I clamp towards the right 180 degrees of the screen? if the player is looking towards the right (angle 0 degrees), the gun should rotate between 270 degrees (down) and 90 degrees (up) but the following doesn't work
Code:
if facing = right
{
image_angle = clamp(point_direction(x, y, mouse_x, mouse_y), 270, 90);
}
What numbers should I put in? I tried having the clamp to be 270 and 450, which also doesn't work. I also tried two clamps depending on where the mouse is, one from 270 to 360, the other from 0 to 90, but I couldn't get that to work either.
Please help!
edit: I just tried having the clamp be between -90 and 90 to see if that would work, but no luck.