Game Development Community

Make an animation work for 5 seconds

by Liam Shalon · in Torque Game Builder · 07/18/2012 (10:14 pm) · 11 replies

Hi,
I'm making a powerup where when the player touches it, it slows it down for 5 seconds.

so I'm thinking of using an if statement to see if the player touches the powerup and then a do while statement to that it slows down the character while the timer hasn't hit 0. any suggestions?

#1
07/19/2012 (4:08 am)
If TGB is similar to T3D, then I would use an onCollision or trigger event that changes $timeScale = 0.1, but will also schedule the $timeScale to equal 1 again after 5 seconds. I am not sure if TGB uses $timeScale so you will have to look into that.
#2
07/19/2012 (4:36 am)
$timeScale should slowdown the whole game not just that single animation.
You could swap the player with another sprite ( I am developing T3D so i might not be using the right terms ) that sprite should play a slowed down animation, then make a schedule when the schedule ends swap the sprite back to the original one.
Or you could do some engine code to make a, slow down animations function.
Of course i don't own TGB neither developed in it so i might be wrong or not know a better way.
#3
07/19/2012 (8:27 am)
well, if it slowed down the entire game that would actually be the best thing for me. But if it does slow down the entire game then would the score slowdown too? The score goes up by the second and the more seconds the player survives the higher his score is.
So the question is, would time scale work in that case?
and
Is there a way to just simply slowdown the character for 5 seconds, maybe set the %val down for 5 seconds.
and if someone thinks that that could work could someone send me a example?
#4
07/19/2012 (8:28 am)
in other words, how do I put the %val down for a timer of 5 seconds or 10 or 15
#5
07/19/2012 (12:18 pm)
If you just wanna slow the characters movementspeed you might wanna have a look at this tutorial

whether the score slows down aswell depends on how you handle it. I believe using the $timescale will slow down the amount of ticks the game is running at. So if you calculate the score based on the real time spent it wont slow down the score but instead slow down the rate at which the score is updated at.
#6
07/19/2012 (12:36 pm)
ya.
#7
07/19/2012 (2:06 pm)
so ya, I'll do that but how do I set the timer?
#8
07/19/2012 (2:09 pm)
What timer? The 5 seconds?
First do whatever you need to do, like setting $timescale to 0.5 then create a schedule kindda like this:
schedule(5000,0,"speedUpAgain");
Read more about schedule here
#9
07/19/2012 (2:26 pm)
Yes! Thank you. The only think that I still have a question about is 1. Should I just move it so that the sensitivity goes down 2. Should I put this into a "if player touches powerup do sensitivity down while the 5 seconds goes. I am programming on itorque just saying
#10
07/19/2012 (2:28 pm)
Oh yeah, I don't know anything about sensitivity but it sounds like you would just need to set it down when beginning the schedule and putting it back up when the schedule has finished :)
#11
07/19/2012 (2:46 pm)
asuming that I have all of my classes sorted out I would be able to make it like this:

if
(Player hits Powerup)
Do
(set sensitivity down)
While
(5 seconds)

Secondly I have a question unrelated to this, how do I move the camera so it keeps going up and if my player hits the bottom edge they die.