-
Q: You have set up an active with four directions (0, 8, 16, 24) each with an animation (loops two times). Then you put some buttons that can add and subtract values to the animation index and direction.
You would expect this to make the object turn 90 degrees each time you click a button, but it only works one time. You have also set a counter to display the animation direction, but it does not work.
Explanation:
The two directions are the "animation direction" (what is displayed) and the "movement direction" (what is stored and used for movement calculations). The problem is that you assume Dir() retrieves the former, where as it actually retrieves the latter.
This mistake is easily made because the "Get Direction value" expression was accidentally put under the Animation sub-menu instead of the Movement sub-menu. There is no way to retrieve the current animation direction because it is not stored anywhere (it is usually determined automatically, derived from the movement direction and available animation directions).
Imagine you have an active object with bouncing ball movement. This object has four animation directions set: Up, Down, Left and Right. In the event editor you set the object's movement direction to be right and up a little (AKA a direction of 1 in MMF2's directional system).
While the object is moving to the right, an dup a little, its animation direction will be as if it were going right. However, if you use Dir("active") then it will give the movement direction of 1 and not the Animation Direction of 0.
If you set the animation direction through events based on the movement direction, it will not change the movement direction and the next time you try to move based on on DIR)"active") it will give the same result because the movement direction has not changed.
If, instead of relying on the movement direction, you stored the animation direction in the object's alterable value, then it would work as you expect. Instead of:
Set animation direction to movement direction + B
You would have:
Add 8 to alterable value A of object
Set animation direction to Alterable value A
A further complication may arise. There are angles which are distinct from directions.
Marv
-
Ahh Marv is right,
you are probably changing "animation direction"
while you should change "direction"
so for your objects not "change animation direction"
but "set direction"
the animation direction should change anyway
but then retrieving animation direction value should work fine
(crossing fingers XD)
-
Thanks everybody for all the effort in trying to figure this out.
I've been at it this whole time and found a workaround that does work but I will for sure remember the correct way to do it next time.
The workaround is: When you equip the gear I set that animation direction value to a global value as well. And THAT'S the value that I save in the ini, and load back.
Lot of extra work for all the stuff but as long as it's done now I'm happy.