How do I Make these "Wait"s Frame-rate independant

Get help using Construct 2

Post » Tue Jan 27, 2015 5:36 pm

I am trying to get the timing right to make a monsters body segments follow its heads path. like a snake but in all directions. I need a way to account for any frame-rate by using dt but I don't really understand how to get it right....

forumpost.jpg



Can I make these wait commands frame-rate independent?
The timing needs to be perfect otherwise the whole thing falls apart.

.capx attached

Also side note: If I use dt in a "On Start of Layout" event does it not work right? I did some testing with a textbox to see if that was so and it seems to not like taking any dt values on the first tick
You do not have the required permissions to view the files attached to this post.
B
4
Posts: 17
Reputation: 234

Post » Tue Jan 27, 2015 9:00 pm

Before getting into fixing this, I'm going to stress something: wait is already frame rate independent, although weird things may happen if you wait really small amounts of time, such as 1/60 of a second(i.e., less than the length of one frame).

That being said, the method you've chosen isn't the best way to go about this, and seems overly complicated for what it is. I've modified your example to demonstrate the behavior I believe you're wanting.

snakeUpdated.capx

I've replaced all of the complicated timing with some basic math. If you're not familiar with trigonometry -- cos and sin are used here -- I'd highly recommend doing a bit of research, as even the most basic trig is an indispensable tool for game creation.

Let me know if you want a more detailed explanation of what's going on.
You do not have the required permissions to view the files attached to this post.
Moderator
B
113
S
41
G
20
Posts: 1,586
Reputation: 19,126

Post » Tue Jan 27, 2015 10:47 pm

Time measured in seconds is framerate independent! This seems to be a common point of confusion, including with 'Every X seconds'.

Believe it or not, waiting 1 second waits for 1 second regardless of the framerate. 1 second doesn't suddenly become longer at 30 FPS :)
Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,351

Post » Wed Jan 28, 2015 5:40 am

Thank you so much! I have literally spent over 30 hours on trying to get this movement correct..... (I am still very new to this stuff so hopefully that's not too pathetic heh). Your updated version is 90% what I want and I can definitely use it to make the movement like I want. Thank you again. I'm going for a movement pattern like "Moldorm" from "Zelda a Link to the Past" if you want to see how the enemy moves.
B
4
Posts: 17
Reputation: 234


Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider] and 9 guests