Speed of ticks after timescale change?

For questions about using Classic.

Post » Mon Sep 05, 2011 2:05 am

Arima described TimeDelta perfectly, which should help you get started with time-based developing.

Just make sure, you stick to one method, either time based or pixel based. Trying to combine those will only give you headaches.

[QUOTE=sparkfeather]If timedelta is FPS independent, how do I do something simple like I would
with ticks, where I want to make an object after 100 ticks,
an amount of time that would be consistent across varying framerates?[/QUOTE]If working time-based, you have to remember that the shortest interval you have still is one tick. If your game runs at 60 fps v-synced, the fastest your code is triggered is every 16.67 ms (1/60). Every time-based condition will trigger either exactly at the given time or as close as possible to it afterwards. For example, every 1 milliseconds will trigger at tick 1, tick 2, tick 3, etc., because the game doesn't run at 1000fps (which would be needed for 1ms).
To have an object being created after a certain amount of time, there are several methods:
- You could use the wait object, delaying the creation
- You could use timer (a system expression). Set a variable 'timestamp' to timer, and compare 'timestamp' against timer and the desired timespan. For example, to create an object 2 seconds after 'timestamp' was set to timer:[code]+ 'timestamp' less or equal timer - 2000
+ Trigger once[/code]
- You could use the timeline object

[QUOTE=sparkfeather]Also from what I understand, if TimeDelta becomes necessary to swap with
all my events currently using ticks, what would be the best way to have
things consistent in their time when I'm using timescale? Have seperate
trees with different times set based on the timescale at the time?[/QUOTE]That confuses me. The whole purpose of timescale is to have an easy way to change the timing behavior of all time-based code at once. So why would you want to change timescale, without wanting to change the behavior of the time-based code?
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Mon Sep 05, 2011 10:10 am

@Arima

So, from that example Arima as I now understand it thanks to your
fantastically layed out and simplified written view of how it works,
because at 1fps timedelta in that expression will result with 100,
and 10fps it will result with 10, the time passes as:
1 x 100 = 100,
and
10 x 10 = 100,
in other words it will end up traveling the same amount.
Thank you so much for that example, it really allowed it to make sense
for me, I greatly appreciate it!

------------------------------------------------------------------
------------------------------------------------------------------

@tulamide

I'm not using this for movement, however I understand what you mean
by only using one method as it would easily unsynch the gameplay
if you were to use different methods in the same game.

Thanks a lot for that information, I hadn't recognized or thought
about that but that certainly makes sense how you put it. An event
can't run every 1ms if it can't register that amount of time passing,
and would make the event occur basically whenever it could, cause
at 60fps every frame that is registered would have passed a millisecond,
and it wouldn't know a millisecond had occurred between those frames
because it wouldn't have been there to find out.
@wait
That I've found is next to useless, it constantly caused errors in
the event hierarchy because it would re-check the above variables
after the time had passed instead of only causing a delay before the
next action occurred.
For example, if you had it check if a private variable were equal to 0
before running some events, one of which would need to change that variable
to 1, when it reached the next action after waiting maybe 200 milliseconds,
the events condition wouldn't be valid anymore and it won't occur.
@timer
that's what I've had to use for objects so far, but it becomes an issue
very easily.
#1 if there is more than one object on the screen (if it's an enemy in which multiple enemies would be created, you couldn't get a timer to
start on individual enemies without it occurring on others. For some objects that I have destroy after a certain amount of time, even if there are multiple you can use that timer by only setting the timer
when a condition that a variable is equal to 0 is met, then change that
to 1 after the timer is set in the same event. But that only works because you only need to use the timer once and it's an event based off the objects creation.
#2 if you want multiple areas of an object to be based off time, it'd very easily become a large hassle and difficult to manage if you kept having to create private variables and setting them to time and checking them.
Both of these issues are the reasons causing me to currently use ticks
for some events, but now I recognize that's certainly no safe option,
however you can't run events after 'x' timedelta or anything like that.
Even with a global variable if multiple objects/events used it it wouldn't help to set a single global variable to 'Time' and keep
setting and then checking after time has passed with that.

The timeline object would in a way share the problems described above
for the timestamp solution.



The reason I want some events to not be affected by timescale, is I want
to slow down the world by using timescale (all events/objects/etc), however
some things I don't want to slow down, for example how long a text object
spawned off an enemy displaying the damage they have taken would last
before being destroyed.sparkfeather2011-09-05 10:41:47
B
3
G
2
Posts: 58
Reputation: 1,166

Post » Mon Sep 05, 2011 12:24 pm

[QUOTE=sparkfeather]@wait
That I've found is next to useless, it constantly caused errors in
the event hierarchy because it would re-check the above variables
after the time had passed instead of only causing a delay before the
next action occurred.
For example, if you had it check if a private variable were equal to 0
before running some events, one of which would need to change that variable
to 1, when it reached the next action after waiting maybe 200 milliseconds,
the events condition wouldn't be valid anymore and it won't occur.[/QUOTE]
I am no friend of the wait object, because it makes event sheets harder to maintain. That's why I never use it. I just proposed it, because quite a few people here swear on it, and I didn't want to hide it ;)

[QUOTE=sparkfeather]@timer
that's what I've had to use for objects so far, but it becomes an issue
very easily.
#1 if there is more than one object on the screen (if it's an enemy in which multiple enemies would be created, you couldn't get a timer to
start on individual enemies without it occurring on others. For some objects that I have destroy after a certain amount of time, even if there are multiple you can use that timer by only setting the timer
when a condition that a variable is equal to 0 is met, then change that
to 1 after the timer is set in the same event. But that only works because you only need to use the timer once and it's an event based off the objects creation.[/QUOTE]
I'm not quite sure if I understand. PVs are unique to every instance, it is just a case of picking right. If I pick one instance and set 'timestamp' to timer, only 'timestamp' of that one instance is set. So, if you want to pick an instance at times, when it is not created, you can do so by picking based on oid or uid, or set an 'pid'-pv on creation.
For a situation, where one object would have to spawn a few instances delayed, there are objects like array or hash table, where you could store the timestamps, test against timer and clear/remove the cells, when creating the corresponding instance. Straightforward and easy to control :)

[QUOTE=sparkfeather]#2 if you want multiple areas of an object to be based off time, it'd very easily become a large hassle and difficult to manage if you kept having to create private variables and setting them to time and checking them.[/QUOTE]
I can't agree here. I use the 'timestamp' method in every project, sometimes on hundreds of sprites and instances. If you carefully prepare your project, you won't get into trouble. Instead, while using something like the wait object would really be a problem under such conditions, it is relatively easy to follow the logic behind the 'timestamp'-events.

[QUOTE=sparkfeather]The reason I want some events to not be affected by timescale, is I want
to slow down the world by using timescale (all events/objects/etc), however
some things I don't want to slow down, for example how long a text object
spawned off an enemy displaying the damage they have taken would last
before being destroyed.[/QUOTE]
I see. Well, this is a situation, where you have to decide, which one is more important to be time-based.
You could, for example, constantly check the framerate (e.g. through getting the mean of 1/TimeDelta) while timescale = 1. Then, when reducing timescale, you'd calculate the proper timing for the text boxes based on that framerate, and alter them tick-based until timescale = 1 again.
Or you could leave timescale untouched and slow the world down by changing all the timebased values, including animation speed, etc. But that would mean a huge effort to make.

I recommend to download Verve!, an example game that is completely time-based. There are a lot of the things realized that you are thinking of (For example, there's a commented volume fade over time, although timescale=0 at that time). I commented every single event, so it should be a good source of information.
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Tue Sep 06, 2011 9:13 am

[QUOTE=tulamide]
I am no friend of the wait object, because it makes event sheets harder to maintain. That's why I never use it. I just proposed it, because quite a few people here swear on it, and I didn't want to hide it ;)
[/QUOTE]

Ahhh no worries, well thank you for pointing out all the options
without limitation :)


[QUOTE=tulamide]
I'm not quite sure if I understand. PVs are unique to every instance, it is just a case of picking right. If I pick one instance and set 'timestamp' to timer, only 'timestamp' of that one instance is set. So, if you want to pick an instance at times, when it is not created, you can do so by picking based on oid or uid, or set an 'pid'-pv on creation.
For a situation, where one object would have to spawn a few instances delayed, there are objects like array or hash table, where you could store the timestamps, test against timer and clear/remove the cells, when creating the corresponding instance. Straightforward and easy to control :)
[/QUOTE]

OID?
I know UID is uniqueID, however that includes all objects in the scene,
and it would be impossible to know which instance of the object you
wanted as well.
I like to use a private variable 'states' to differentiate them somewhat,
so when a creature enters the 'attacking' state it would change to the
attack animation, and spawn a weapon/ranged attack/effects on frame 3,
it would know to check for frame 3 of an enemy instance in the attacking
state, however how would I get the weapon/ranged attack/effect to spawn
at that enemy specifically. Because it wouldn't know which of the enemys
positions to spawn at.
I've tried with the enemy damage text, when an object is overlapping it
I have the text spawn at the enemy once by using 'trigger once',
however if there are multiple enemies, it will cause it to only create
a text at one of the enemies you are overlapping.
I've tried using the 'for each' event condition, but it causes one enemy
to have the text created once like it should, but the other enemies that
are overlapped continuously spawn the object while they are overlapped.
No matter what I do I can't seem to have events run while considering
only the individual object they are running at and it's parameters/location, etc.


[QUOTE=tulamide]
I can't agree here. I use the 'timestamp' method in every project, sometimes on hundreds of sprites and instances. If you carefully prepare your project, you won't get into trouble. Instead, while using something like the wait object would really be a problem under such conditions, it is relatively easy to follow the logic behind the 'timestamp'-events.
[/QUOTE]

What happens when you need to know that one area of an object you need
a timestamp for won't overlap another area. You just make multiple timestamps?


[QUOTE=tulamide]
I see. Well, this is a situation, where you have to decide, which one is more important to be time-based.
You could, for example, constantly check the framerate (e.g. through getting the mean of 1/TimeDelta) while timescale = 1. Then, when reducing timescale, you'd calculate the proper timing for the text boxes based on that framerate, and alter them tick-based until timescale = 1 again.
Or you could leave timescale untouched and slow the world down by changing all the timebased values, including animation speed, etc. But that would mean a huge effort to make.
[/QUOTE]

While reading over that, thanks to it I was inspired to another possible
solution.
I could have a global variable that's set to 1, and have every event
where I use multiply by that global variable, and then with the events
where I cause the timescale to for example be set to 0.2, I could set
that variable to 5, automatically causing the time for those events
to balance out. Would that be a good solution?


[QUOTE=tulamide]
I recommend to download Verve!, an example game that is completely time-based. There are a lot of the things realized that you are thinking of (For example, there's a commented volume fade over time, although timescale=0 at that time). I commented every single event, so it should be a good source of information.
[/QUOTE]

Thanks for that recommendation, I've looked over it a bit and it's a
great example, I'll be sure to delve into it deeper before responding
again, and once again thanks so much for taking your time to help me like
this, I appreciate it so much! ^^sparkfeather2011-09-06 09:16:37
B
3
G
2
Posts: 58
Reputation: 1,166

Previous

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests