2 registered members (alibaba, vicknick),
1,492
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Frame skip problem
#457529
01/21/16 15:47
01/21/16 15:47
|
Joined: Jun 2010
Posts: 71
LawnmowerMan
OP
Junior Member
|
OP
Junior Member
Joined: Jun 2010
Posts: 71
|
In my code I use next example for play some function
if(button_pressed == 1 && my.animation > 80 && my. animation < 85)
{
start function
}
It works well if everything is fine with the frame rate, but if the fps drops, simply this part of animation is skipped and my function wont start. What should I do to prevent the frame skip? I use time_step for play my animations.
|
|
|
Re: Frame skip problem
[Re: LawnmowerMan]
#457544
01/21/16 21:40
01/21/16 21:40
|
Joined: Jan 2006
Posts: 968
EpsiloN
User
|
User
Joined: Jan 2006
Posts: 968
|
Maybe try testing against .frame ?
If my.frame > anim start frame && my.frame < anim end frame
Also, just a suggestion, don't limit the upper frame boundary, make a check to see if the animation already played some function this loop and reset it after the animation loop ends. This way, no matter what, the function will trigger at 80% or above. PS.: Keep in mind, that working with animate functions means working with percentage, while accessing the ".frame" skill means direct access to the current frame number that is being played (no matter if its in the middle of interpolation between the next frame, I think)... so you could trigger it every time on a specific frame.
Last edited by EpsiloN; 01/21/16 21:42.
|
|
|
Re: Frame skip problem
[Re: EpsiloN]
#457554
01/22/16 11:11
01/22/16 11:11
|
Joined: Dec 2011
Posts: 1,823 Netherlands
Reconnoiter
Serious User
|
Serious User
Joined: Dec 2011
Posts: 1,823
Netherlands
|
Yeah cause of time_step and slow fps my.animation probably almost never becomes between 80 and 85. I would use a variable your entity skill as check (make non-zero when you need to call the function and make zero again when you call the function). But it seems EpsiloN's idea is cleaner so try that first. ps: is it only for 1 entity?:
if(button_pressed == 1 && my.animation > 80)
{
button_pressed = 0;
...
}
Last edited by Reconnoiter; 01/22/16 11:13.
|
|
|
Re: Frame skip problem
[Re: LawnmowerMan]
#457585
01/22/16 19:31
01/22/16 19:31
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
"> .. <" cases are generally a bad idea in such a time sensitive case. Using a secondary variable as already suggested is (IMO) the correct approach, I do that too.
my.anim +...
if(my.anim < 80) my.do_action = 1;
else
{
if(my.do_action)
{
my.do_action = 0;
... do something
}
}
Using fps_min is not the worst idea, in general. I have it set to 15 and I make sure everything works fine (including flying projectiles/ movement/ moving platforms/ ...) at that low framerate, and with fps_min the code and gameplay will work on all systems with a non-zero FPS that way. Btw. if you really need something to start at let's say (anim == 80), then increase it to that value first (with a limit to 80), then do your action and continue up to 100 after that.
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
Re: Frame skip problem
[Re: LawnmowerMan]
#457602
01/23/16 18:10
01/23/16 18:10
|
Joined: Jan 2006
Posts: 968
EpsiloN
User
|
User
Joined: Jan 2006
Posts: 968
|
If you use fps min, I think, you're limiting the minimum FPS to 50, but only for calculations. Pentium II cant give you 50 fps... Another thought to try out, think how many frames you have for this certain animation, and how fast you go through them in frames/sec and model frames/sec. If you have to, reduce or increase the number of frames on the model itself (will need additional animation but its the only other thing to try out after everything else...)
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|