The Daily Click ::. Forums ::. Klik Coding Help ::. Creating a "slow time" effect
 

Post Reply  Post Oekaki 
 

Posted By Message

aphant



Registered
  18/05/2008
Points
  1242
11th November, 2008 at 06:30:22 -

I'd post this as an article, but I think it's too poorly tested to be article material.

This is a simple way to create a slow motion effect. Just make a new global value, name it time and set it to 1. To make time faster, set the value higher than 1. To make time slower, set the value lower than 1. Do NOT use 0 to "freeze" time! (It might crash your game later, if you decide to divide by time.)

Now, in every event where you're moving something by an amount, just add "*time" to get "amount*time". (Parentheses may help.) For example (below), we have two moving platforms, normally moved using "set X to X+amount". To make them influenced by our time effect, we make that "set X to X+(amount*time)".

That's it!

Well, not entirely. If you look at the example (below), this isn't a perfect method. If you're moving by an odd amount, like 3, then you're going to have a platform that will move faster going to the left than the right when you slow time down (by setting it to 0.5 or something). This can probably be fixed, though.

Now, that's it. Though, you could always extend this concept further. You could make behaviours for different objects that apply the time effect to their own variable (set Alt Value A to Global Value A), and have them react to time dilation differently. You could have an enemy that is immune to the effects of time control, either by omitting the behaviour or omitting the 'amount*time' function from their movement events. You could have puzzles where traps are effectively oppositely by time, by using an 'amount/time' function; 0.5 would make it faster while 2.0 would make it slower. In fact, in the example (below), the moving platform on the right (purple) has this "negative" behaviour!

And here's the example file: http://www.pfordee.com/psychophan7/timewarp.mfa

 

\/\/olf

Creative Genius

Registered
  06/08/2005
Points
  76

VIP Member
11th November, 2008 at 07:41:18 -

Awesomeness. I was thinking of applying such a thing to my game. But in it everything but the player is affected by time so you can have the cool castlevania type time stop effect

 
Image

www.OldMansTale.net
Sign the Petition! Go go Go!!

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
11th November, 2008 at 11:03:36 -

I'm tempted to say "Use the time scaling option in Construct"

Yeah, your idea should work, if I understand it right. Heck, it should be used for every game, slow motion or not, because the timers in games are out of sync with the frame rates, so it would get rid of quite a lot of bugs, especially in movement engines.

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

JetpackLover



Registered
  01/03/2007
Points
  212
15th November, 2008 at 19:21:07 -

Wow cool beans!! Would this time effect only work in a completely custom engine?

 
http://www.invincibletime.com/

Devlog for HD MMF Game Omulus. Check it out because it's gonna be awesome. http://omulus.tumblr.com/

Follow me on the twitters https://twitter.com/JetpackLover


Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
15th November, 2008 at 22:08:35 -

There is another way to do this (only with a custom engine though), but I have to wrok out how to explain it in my head though. It's only an "effect" though. It's not the "proper" way to do it.

 
Craps, I'm an old man!

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
16th November, 2008 at 01:31:05 -


Originally Posted by DudeHuge
Wow cool beans!! Would this time effect only work in a completely custom engine?


If you're doing it in MMF2, it could only be made with a custom engine. Um, most things would be made in a custom engine. Nobody uses MMF2's built-in platform engine anymore

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

-J-



Registered
  05/10/2008
Points
  228

VIP MemberThe Cake is a Lie
16th November, 2008 at 09:59:40 -

"Nobody uses MMF2's built-in platform engine anymore "

There's even a tutorial link on the Clickteam website that tells you how to make a better one

 
n/a ...

Remius Norumenu



Registered
  03/10/2008
Points
  6
4th January, 2009 at 08:01:49 -

I believe ive developed a superior method in my custom engine, although i dont know if it'll work with people who code differently from me. This method is also PERFECT for people who have laggy games because they create too many objects on the screen too fast, and ill tell why later.

Basically you have 2 values. A frame timer, and the frame limiter. You use the Fastloop extension and always run a loop that adds 1 to the frame timer at all times, so that it matches the amount the FPS.

(In my app, there is an active object in the frame that stores these values, but it really doesnt matter.)

This value will count how many frames go by, and will continue to increase. The second value, (Frame Limiter) can be altered at anytime during the level. This value is to reset the frame timer once the number of counted frames meets/exceeds the Frame Limiter value.

1)Always = start loop(frametimer) for (60 loops) <--(or whatever the FPS is)

2)On loop (timerloop)= Add (loop step) to Alt value (Frame Timer)

3)When Alt Value (Frame Timer) is >= to Alt Value (Frame Limiter) = set Alt Value (Frame Limiter) to 0.


Now, in every frame where an object is being moved, or anything that has to do with time, put in the event (Frame Timer = 0). To freeze the animation of the character, put the event --Alt Value (Frame Timer) > 0 = Stop animation). Do the same to continue the animation once the timer is at zero again.

To create the Slow motion effect, simply increase the Frame Limiter by a number. it will stop the movement and animation of everything you told it too by however many frames you set the Frame Limiter to.

No crashing, no FPS screwups, and best of all, you can keep some things moving perfectly while others are in the slow motion state. You can even create more than one Frame Timer value, in order to slow some things down more/less than others, or to create a "superspeed" effect for the player.



The only drawbacks to this method are that it LITERATELY limits movement by however many frames you set the limiter to. Therefore, if an object is moving extremely fast and you slow it down, it will appear to be teleporting distances because everytime it moves, it will move the amount of pixels its supposed to. (in other words, no inbetween frames, unless you program it to move the inbetween pixels during its slow time.)

Also, for this same reason, objects that are slowed down too far may give the illusion of the FPS of your application running EXTREMELY slow, even though its running perfectly fine. If your character is slowed down and the camera is following him it will skip around while it follows them. (otherwise, if the only point of reference is slowed down, everything will look laggy lol.)

Theres a way around this, you just have to be smart.
------------------------------------------------------------

Im also sure some of you have met the problem with FPS rape when you create items too fast. This (most of the time) is because of the MMF Timer events. (every xx.xx secs, create X.) The MMF timer follows the clock of the computer, not the framerate of the application. Because of this, when you create objects that start to slow the framerate, the timer event that creates them continues to create them at regular intervals, which in essence is FASTER than it was before the application started to slow down, severly worstening the situation, creating objects faster than they destroy themselves.

By using a method similar to the one i explained above, even if you are severely slowing down your application, you will still be creating objects at the exact same intervals, since you are timing them by frames instead of seconds that dont follow the application, which will stop your application from eventually freezing itself up.

Only drawback to this is to completely replace the clock, you'll need to create your own timers by syncing up multiple counters/values to the framerate. However, the performance of your game will increase dramatically.


--Remius

Edited by Remius Norumenu

 
Well well well.



That is all.

NeoMonkey

Finnish Army Fire Commander

Registered
  01/12/2006
Points
  243

VIP Member360 OwnerI am an April FoolPS3 Owner
4th January, 2009 at 11:21:32 -

http://theclickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=98255#Post98255

Here you have nice slow motion example.

 
I have proven new mathematic formula to be true...

2D > 3D

Image


-J-



Registered
  05/10/2008
Points
  228

VIP MemberThe Cake is a Lie
4th January, 2009 at 12:36:19 -

Now to remake The Matrix with Multimedia Fusion!

 
n/a ...

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
5th January, 2009 at 11:45:21 -

Yay, I was beginning to think no one ever reads my articles

 
191 / 9999 * 7 + 191 * 7

W3R3W00F

Drum and Bass Fueled Psycho

Registered
  08/11/2008
Points
  368

VIP MemberCardboard BoxThe Cake is a Lie
5th January, 2009 at 17:30:08 -


Originally Posted by DeadmanDines
Yay, I was beginning to think no one ever reads my articles



Lol You've got to be kidding me. I love your articles!

Edited by W3R3W00F

 
n/a

[DELETED]

Likes to put dots on paper

Registered
  08/12/2008
Points
  118

MushroomVIP MemberARGH Sign
6th January, 2009 at 13:19:48 -

@Shab: I suppose there's no "proper" way to create bullet-time/slow-motion, as we need to manually change the speed of everything when we want to use it and have to individually manipulate everything rather than just tell the entire game; "Slow down a bit!"

 
n/a
   

Post Reply



 



Advertisement

Worth A Click