Hi,
So I'm working on a little (sort-of isometric) real-time strategy project. I've made a unit (tank) find and drive towards a point set by right-clicking.
I have two objects:
- The pathfinding object, set to invisible
- The sprite object, pinned to the pathfinding object
I've made 72 separate sprites of the tank to complete a 360-degree view of the tank. I've also made 72 events for every sprite, checking if the pathfinding object is between angle-1 and angle-2. (I'm sure there's a better way for doing this, but it is not something I want to worry about right now.)
The thing is that the sprite object will rotate every 5 degrees, but the pathfinding object can rotate in decimals too, meaning that if the tank sprite is angled at 45 degrees, and the pathfinding object is angled at 46.65765748547489 degrees, it will look like the sprite is slightly sideways. The temporary solution is to check if the pathfinding object is between 2 angles, but I want to eliminate that concept and check if the object is rotated at exactly X degrees.
EDIT: Ignore the sprites and how I've coded/made them, it's the green box in the 3rd picture I'm trying to fix.
Here's an example:
The numbers are the actual angle of the pathfinding object, but the sprite image is angled at 0/360.
I want the pathfinding object to snap to 0/360.
Here's also an example of the "slidey" movement (when moving, after rotating).
Finally, here's an example of the misalignment because it's not the exact angle.
My question is: Is it possible to snap the rotation of the pathfinding object, so it can only rotate towards degrees 0, 5, 10, 15, 20 etc.?
Thanks in advance.