Looking in only specific Angles
Is there any easy mathematics I can use in a "set direction" command after a "look in direction of" command that will make an object look in the direction of another object but only in... let's say four directions since my game I'm working on currently has four directional movement.
Re: Looking in only specific Angles
If I understand correctly, the only thing that comes to mind is making four events on each of which you will be comparing position of object 1 to position of object 2 and then setting direction accordingly, like this:
xpos1 > xpos2: set direction to 16
xpos1 < xpos2: set direction to 0
ypos1 > xpos2: set direction to 8
ypos1 < xpos2: set direction to 24
There might be other ways to do this but they might not necessarily be faster.
Re: Looking in only specific Angles
I already know that method, I was wondering if there was a mathematic formula that could round a number to multiples of 8.
Re: Looking in only specific Angles
Try: (value)/8x8
I use this all the time to force actives to align to a grid. Should work for your purposes too.
Re: Looking in only specific Angles
Nearly, but that actually won't work, because MMF2 will always round-down (instead of rounding down/up to the nearest whole number).
The proper solution is:
Round(Dir( "Active" )/8.0)*8
Note: In addition to using "Round()", you also MUST include the ".0"
Re: Looking in only specific Angles
Thanks, it works like a charm and was easy to implement on top of that.