Hey mates, hope you all are well!
What I'm trying to do is get the players current game speed, store it as a variable and use it to return the game to the speed the player had previously selected, after an animation- because- I'm slowing the game down to default (40) before most animations.
What I tried that isn't working is this
//created global variable "PrevSpeed" (int)
//In room script under interact function for animation
PrevSpeed = GetGameSpeed();
SetGameSpeed(40);
oObject.Animate(0, 0, eOnce, eBlock, eForwards);
SetGameSpeed(PrevSpeed);
I had used something similar to return the player to the previous room and location (if they cancel out of using the map by pressing Return) and it worked so I thought this would but alas.
Thanks for any tips :)
EDIT: the above example works, I had another setgamespeed set in the room script that I had missed (whoopsie). If you searched your way here for help, using the above example will work :)
What part isn't working?
Apologies, it is working. I had a rogue setgamespeed in the room script that I didnt see and forgot about. I feel shame.
Thanks for the help though!
I suggest you create a custom pointer function to animate your objects that need the game speed slowed down.
Since it would be much easier for you to write the function once, and then just type MyAnimation(oObject);, than having to type all those lines everytime you want to animate an object. ;)
Why are you allowing the player to change the game speed in the first place? Maybe there's a different solution that doesn't require changing the speed?
Is this about the character's walking speed?
Anyway, you can do this:
//header
import void AnimateS(this Object*, int loop, int delay, Direction dir);
// top of main script
void AnimateS(this Object*, int loop, int delay, Direction dir) {
PrevSpeed = GetGameSpeed();
SetGameSpeed(40);
this.Animate(loop, delay, eOnce, eBlock, dir); // eBlock is a given, therefore so is eOnce
SetGameSpeed(PrevSpeed);
}
Now you can do
oObject.AnimateS(0, 0, eForwards);