Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,213 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Frame skip problem #457529
01/21/16 15:47
01/21/16 15:47
Joined: Jun 2010
Posts: 71
L
LawnmowerMan Offline OP
Junior Member
LawnmowerMan  Offline OP
Junior Member
L

Joined: Jun 2010
Posts: 71
In my code I use next example for play some function
Code:
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 Offline
User
EpsiloN  Offline
User

Joined: Jan 2006
Posts: 968
Maybe try testing against .frame ?
Code:
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.

Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201
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 Offline
Serious User
Reconnoiter  Offline
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?:
Code:
if(button_pressed == 1 && my.animation > 80)
{
  button_pressed = 0;
  ...
}


Last edited by Reconnoiter; 01/22/16 11:13.
Re: Frame skip problem [Re: Reconnoiter] #457584
01/22/16 19:09
01/22/16 19:09
Joined: Jun 2010
Posts: 71
L
LawnmowerMan Offline OP
Junior Member
LawnmowerMan  Offline OP
Junior Member
L

Joined: Jun 2010
Posts: 71
Thank you guys for help, I already know this should works with only my.frame > 80 but I need that upper limit because exactly in this part of the animation player make the choice of whether something will happen or not. I tried to use fps_min and fps_max but did not help. I guess I have to make it in some other way

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 Offline
Senior Expert
Superku  Offline
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.

Code:
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: Superku] #457597
01/23/16 16:32
01/23/16 16:32
Joined: Jun 2010
Posts: 71
L
LawnmowerMan Offline OP
Junior Member
LawnmowerMan  Offline OP
Junior Member
L

Joined: Jun 2010
Posts: 71
Thank you Superku I will follow your suggestion and try with second variable. Can you please explain why you use so low fps_min? In my game I use fps_min 50 and fps_max 60, is it okay? I think it's better if the game goes slow, but to comes to big frames skipping. I control a lot of things in the game through animation, and I fear that my game would not work well on weaker PC. I'm not sure that fps_min really can help here.

Re: Frame skip problem [Re: LawnmowerMan] #457602
01/23/16 18:10
01/23/16 18:10
Joined: Jan 2006
Posts: 968
EpsiloN Offline
User
EpsiloN  Offline
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... laugh

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 laugh but its the only other thing to try out after everything else...)


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1