Advertisement

Steeering behaviours

Started by June 16, 2006 12:19 PM
18 comments, last by gorogoro 18 years, 5 months ago
Quote: Original post by gorogoro
So I changed the Update code to something like this:

*** Source Snippet Removed ***
But that if is really really ugly. And things are kept hard coded. :s


I didn't mean to clamp it in here, but immediately when you're geting the value from the timer (possibly in the main loop). This kind of hardcoding is well known - it enforces slowdown of the gameplay when desired frame rate cannot be achieved.

Quote: Original post by gorogoro
By the way with this if statment the thing works just fine.


Good for you!
Now go fix that mass/force issue I was bugging you about before.
~def
Quote: Original post by deffer
Quote: Original post by gorogoro
So I changed the Update code to something like this:

*** Source Snippet Removed ***
But that if is really really ugly. And things are kept hard coded. :s


I didn't mean to clamp it in here, but immediately when you're geting the value from the timer (possibly in the main loop). This kind of hardcoding is well known - it enforces slowdown of the gameplay when desired frame rate cannot be achieved.

Quote: Original post by gorogoro
By the way with this if statment the thing works just fine.


Good for you!
Now go fix that mass/force issue I was bugging you about before.
~def



ARGH! I'm freaking out and running out of time! I don't now how to fix this stuff :p. Because the value 0.0065 (if(elapsedTime > 0.0099)elapsedTime = 0.0065) is working on my computer. But who garanties that it is still going to work on other computer or even at XBox360?? :S DAmned.

I'm looking to the files, with lot of values, and I don't now what to do. This elapsedTime is messing me a lot.

Here is the code I'm using to calculate the elapsedTime:

	static double lastTime = Core::GetTimer().GetTimeSec();			double curDeltaTime = Core::GetTimer().GetTimeSec() - lastTime;						// update last time			lastTime += curDeltaTime;


Wich is done at every rendering step!

The elapsedTime is the lastTime variable.
Advertisement
Quote: Original post by gorogoro
Quote: Original post by deffer
Quote: Original post by gorogoro
So I changed the Update code to something like this:

*** Source Snippet Removed ***
But that if is really really ugly. And things are kept hard coded. :s


I didn't mean to clamp it in here, but immediately when you're geting the value from the timer (possibly in the main loop). This kind of hardcoding is well known - it enforces slowdown of the gameplay when desired frame rate cannot be achieved.

Quote: Original post by gorogoro
By the way with this if statment the thing works just fine.


Good for you!
Now go fix that mass/force issue I was bugging you about before.
~def



ARGH! I'm freaking out and running out of time! I don't now how to fix this stuff :p. Because the value 0.0065 (if(elapsedTime > 0.0099)elapsedTime = 0.0065) is working on my computer. But who garanties that it is still going to work on other computer or even at XBox360?? :S DAmned.

I'm looking to the files, with lot of values, and I don't now what to do. This elapsedTime is messing me a lot.

Here is the code I'm using to calculate the elapsedTime:

*** Source Snippet Removed ***

Wich is done at every rendering step!

The elapsedTime is the lastTime variable.


One thing I just remembered now. I'm always using the World cordinate system. Could it be wrong? Should I use the local coordinate systems?
Quote: Original post by gorogoro
Here is the code I'm using to calculate the elapsedTime:

*** Source Snippet Removed ***

Wich is done at every rendering step!

The elapsedTime is the lastTime variable.


You should definitely use "curDeltaTime" variable.

static double lastTime = Core::GetTimer().GetTimeSec();double curDeltaTime = Core::GetTimer().GetTimeSec() - lastTime;			// update last timelastTime += curDeltaTime;const double timeDiffToUpdate = clampMinMax(curDeltaTime, 0, 1.0/g_MinFrameRate);// do various updates using only "timeDiffToUpdate" variablemyAgent.Update(timeDiffToUpdate);myCamera.Update(timeDiffToUpdate);// ...


Actually, you should check if this actually is the problem you were facing and "you think" you've resolved. Is "curDeltaTime" happen to be negative sometimes? Is it exceeding some high treshold value? If both answers are: no - the problem lies totally elsewhere.

Quote: Original post by gorogoro
One thing I just remembered now. I'm always using the World cordinate system. Could it be wrong? Should I use the local coordinate systems?


It hardly matters, so you ought to use the one that more intuitively fits the concept. In other words, nope, you should stick to World Coordinates.
Quote: Original post by deffer
Quote: Original post by gorogoro
Here is the code I'm using to calculate the elapsedTime:

*** Source Snippet Removed ***

Wich is done at every rendering step!

The elapsedTime is the lastTime variable.


You should definitely use "curDeltaTime" variable.

*** Source Snippet Removed ***

Actually, you should check if this actually is the problem you were facing and "you think" you've resolved. Is "curDeltaTime" happen to be negative sometimes? Is it exceeding some high treshold value? If both answers are: no - the problem lies totally elsewhere.

Quote: Original post by gorogoro
One thing I just remembered now. I'm always using the World cordinate system. Could it be wrong? Should I use the local coordinate systems?


It hardly matters, so you ought to use the one that more intuitively fits the concept. In other words, nope, you should stick to World Coordinates.



Thanks a Lot for all your support!
It was my mistake, I'm using the curDeltaTime off course.
It never have negative values. But sometimes I guess it gets values to big (thats's when it gets bad values).
Your saying that I should clmap the value to be in a certain range. But What range? How could I know what is the acceptable range??
One that doesn't produce glithes. Try it out for yourself.
Advertisement
And is that procedure OK? Is it usual to do in games?
I should say that this game is going to be plattform independent (should work on PC and Xbox for now, but later it is going to work on ps3 and other consoles).
Quote: Original post by gorogoro
And is that procedure OK? Is it usual to do in games?
I should say that this game is going to be plattform independent (should work on PC and Xbox for now, but later it is going to work on ps3 and other consoles).


If that's the case, then it is not OK.

Bottom line is: this should work without any clamping whatsoever. If you are sure that timer is giving you values that are causing glithes, then you should definitely talk to the guys responsible for that module. On the other hand: I personally doubt that it is timer's fault, even thought you said that after clamping things run smoothly.

Again, I advice you to debug your code step-by-step in your debugger to see with your very eyes how the glithes are born. Without this you're dancing in the dark, and even won't be able to convince anyone in your team that they should help you about it. Try using some fake-timer values, so you could be reproducing the situation in different scenarios, causing the glithes or not - thus giving you some general direction - and then, using values that you're sure are causing glitches, examine the code flow thoroughly in your debugger.
OK! Once more thank you a lot for the suport!

Now you can call me stupid!
Bug fixed and as all bug this was a really really stupid thing!
In the beggining of the project I make this:

[source snap="cpp"]//TODO: talk to the guy of fisycs to set this properly using phisics engineVector3f GetVelocity(){  return Vector3f(0,1,0);}


And I forget it completly even when I was updating the m_velocity value.
ARGH!!!!!! Now I'm going to jump of a bridge. :p
OK! Once more thank you a lot for the suport!

Now you can call me stupid!
Bug fixed and as all bug this was a really really stupid thing!
In the beggining of the project I make this:

//TODO: talk to the guy of fisycs to set this properly using phisics engineVector3f GetVelocity(){  return Vector3f(0,1,0);}


And I forget it completly even when I was updating the m_velocity value.
ARGH!!!!!! Now I'm going to jump of a bridge. :p

This topic is closed to new replies.

Advertisement