Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: A time question  (Read 10998 times)

0 Members and 1 Guest are viewing this topic.

zarka

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
A time question
« Reply #15 on: October 01, 2008, 04:21:45 pm »
have your tried to multiply this line by frametime as well ?
Code: [Select]
y += force - offset;

might solve it (not that i have look deeply into your code yet but if that doesn't work i will try to do that)
//Zzzarka

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
A time question
« Reply #16 on: October 01, 2008, 05:29:11 pm »
Didn't work. the variable force has already been multiplied with the frame time when we get to that line of code.

Code: [Select]
if(!standing)
force += gravity * frameRate;

zarka

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
A time question
« Reply #17 on: October 01, 2008, 06:12:05 pm »
Quote from: "dabo"
Didn't work. the variable force has already been multiplied with the frame time when we get to that line of code.

Code: [Select]
if(!standing)
force += gravity * frameRate;


strange... oh well i'm heading home from work now i will see if i can have a look at it when i get home ...
//Zzzarka

dabo

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
    • http://www.dabostudios.net
A time question
« Reply #18 on: October 01, 2008, 09:43:37 pm »
ok, thanks.

zarka

  • Jr. Member
  • **
  • Posts: 81
    • View Profile
A time question
« Reply #19 on: October 08, 2008, 08:12:38 pm »
i don't know if you fixed this alredy but i finaly managed to remember to check this whan i was home and able to :)..
The problem is as others have pointed out this row:
Code: [Select]
y += force - offset;

The reason is that your MAX_FORCE constant is not time based .. meaning that when your force reaches MAX_FORCE it will be frame rate depandant and not frame time depandant as you whant it to be :)

so heres a solution:
Code: [Select]

//change it to a static const to keep c++ typesafety
static const float MAX_FORCE = 205.f;
...
//gravity should realy be a constant :)
const float gravity = 31.4f;
...
//and here we make sure it is kept time based
y += (force - offset) * frameRate;


now this should work fine :)
//Zzzarka

 

anything