Apologies for the double post-look , but a new question after fooling around for a specific object bullet behaviour. I wish to achieve the following behaviour for an object bullet.
> Boss tosses a bullet (aimed or random) with a certain angle
> bullet hits the walls and starts moving exactly along the walls
> it moves either clockwise or counter-clockwise based on approach angle.
I'll try to roughly show it:
task bullet(.....) {
while() {
if(bullet hits "ceiling/floor") {
> Change angle 90 degree exact horizontal (so it goes up or down)
}
if(bullet hits "walls") {
> Change angle 90 degree exact vertical (so it goes up or down)
}
}
}
Important behaviour note: If the bullet is shot "towards left-down", when hitting the edge of the field it will move counter-clockwise. Example:
bullet is shot at 179 = make bullet move counterclockwise
" 181 = make bullet move clockwise
" 180 = random choice
" 89 = make bullet move counterclockwise
" 91 = make bullet move clockwise
etc...
What I attempted I managed to get the bullet to change exact horizonta/vertical direction by calculating the "needs adjustment angle". Because if a bullet would fly 260 degrees (upwards) and you want to make it move counter-clockwise, the angle needs to be:
-90. But -90 would make the bullet not travel at 180 degree (left), but at 170 degree. Because
260-90 = 170. So I need to calculate the initial approach. How I did for ceiling was: track bullet angle with constant updating
let dir = ObjMove_GetAngle(obj); and then
let adjustDir = 270 - ObjMove_GetAngle(obj); followed by
dir = dir - 90 + adjustDir. So the calculation becomes
adjustDir = 270 - 260 = 10 which will do:
> dir = dir - 90 + adjustDir
> dir = dir - 90 + 10
> dir = 260 - 90 + 10
> dir = 170 + 10
> dir = 180
Actual problemRight, so here comes the problem. I can probably calculate this for every side of the field but the problem is the bullet will get into trouble when approaching the corners. Because the way my statements listen, 2 statements will trigger and start forcing the bullet odd forms making it either not move or shake around.
At this point I started fucking up by overcomplicated and probably useless scripting methods. Probably there is an easier method to achieve my behaviour but I fail to see at this point.
Edit:- Elaborated the specific behaviour with angle examples
- Eventually I want to bullet to stop moving along the walls but just "leave" or perhaps make it "explode" "disappear" but that is lesser issue atm.
- Awesome mspaint explanation.