Jump to content
  • Advertisement
Sign in to follow this  
mind in a box

Framerate based smoothing

This topic is 2996 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So, I have another problem: I want my Camera to move and rotate smoothly, but I just can't figure out how to do this FPS based. what I mean is: When you have a player, and you add 1 to hims location every frame, he will be too fast with many FPS, and too slow with low FPS. To fix this, you can easily do Speed/FPS, but what can I do when I want it smooth? Here is what I'm currently doing:
void Camera::Tick()
{
	bool bDoneSomething=false;
	if(SmoothLocation!=D3DXVECTOR3(0,0,0))
	{
		Location+=SmoothLocation;
		SmoothLocation*=SmoothSpeed;
		bDoneSomething=true;
	}

	if(SmoothRotation!=D3DXVECTOR3(0,0,0))
	{
		Rotation+=SmoothRotation;
		SmoothRotation*=SmoothSpeed;
		bDoneSomething=true;
	}

...

SmoothSpeed is a float at 0.5. Can you help me with this?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by mind in a box
Yes, thats a nice tutorial, but where is the stuff about smooth moving objects? Or did I just missed it?
The coded uses a timer class that averages the last few frames to smooth out spikes, and then uses that smoothed time to move objects based on a speed in units / sec and the time elapsed that frame.
The actual object update is done in D3DWindow::UpdateLogic() and Sprite::Tick().

Share this post


Link to post
Share on other sites
This is very useful, and I'm building it in at the moment, but not exactly that what I wanted. Just imagine you control a spaceship. When you touch one of your move-keys, it will move. What else, its a move key :P. But when you release it, the ship will need some time to stand still. Your Tutorial seem to be only about smoothing the FPS, and not about FPS based smoothing...

Share this post


Link to post
Share on other sites
Quote:
Original post by mind in a box
This is very useful, and I'm building it in at the moment, but not exactly that what I wanted. Just imagine you control a spaceship. When you touch one of your move-keys, it will move. What else, its a move key :P. But when you release it, the ship will need some time to stand still. Your Tutorial seem to be only about smoothing the FPS, and not about FPS based smoothing...


You aren't describing FPS-based smoothing, though, you're describing inertia. For that you want to look into things like springs, damping and friction :)

Share this post


Link to post
Share on other sites
Yes, maybe. I don't know. When you multiply a value every frame with 0.9 it will go to 0 smoothly. Thats what I want to do, but with implying the FPS.

I just want that my Camera has a smooth rotation...

Share this post


Link to post
Share on other sites
Like:

Position += Velocity * deltaTime;
Velocity *= 0.9f * deltaTime;

Where deltaTime is the amount of time between this point and the last frame.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!