I have an enemy that teleports around the player and shoots a bullet at you using angle(x1,y1,x2,y2). However, I want to limit the angle to -80 and +80 of the enemy's current angle so it's always shooting outwards / the bullet never overlaps the enemy itself, which I'm using clamp() for. This causes some problems because of the way angles work...i.e. if the enemy's angle is 270 (upwards) and the player is to the bottom left of it, it'll actually shoot as far to the right as it can instead of the left.
Any idea what to do about that? I remember MMF having an extension for this very thing...
Develop games in your browser. Powerful, performant & highly capable.
have you tested this pseudo code?
set angle random (max(-80,angle(x1,y1,x2,y2)),min(angle(x1,y1,x2,y2),80))
After you create the bullet and the enemy with the same angle as the enemy then this action should do it.
Bullet: Rotate min(80, anglediff(angle(enemy.x,enemy.y,player.x,player.y), enemy.angle)) degrees toward (player.x, player.y)
R0J0hound As usual R0j0 saves the day. Thanks man