Jump to content

Equal game speed


AggrorJorn
 Share

Recommended Posts

I am having trouble getting many different animations and camera settings to have the same speed no matter what the FPS of the game is.

 

Here is an example of what I am doing at the moment:

UpdateAppTime()

--Rotate object
if KeyDown(KEY_E)==1 then
	object:Turn(Vec3(0,obj.Rotation.y + (0.2 / AppSpeed()),0))

elseif KeyDown(KEY_D)==1 then
	object:Turn(Vec3(0,obj.Rotation.y - (0.2 / AppSpeed()) ,0))
end 


fw:Update()	

fw:Render()

 

Updated values for rotation etc always use a 'divide by AppSpeed() ' to have the same amount rotation no matter what the FPS. What do I need to do here to get the same rotation no matter what the FPS is?

Link to comment
Share on other sites

You need to multiply by AppSpeed(), not divide.

By dividing you only make the FPS speed effect worse :)

 

And you should also not call UpdateAppTime(), since Framework does that already.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Thanks for the quick reply Lumooja.

 

You need to multiply by AppSpeed(), not divide.

ow... well thats just really sad. I have been doing that since I bought LE. lolz

 

By dividing you only make the FPS speed effect worse :)

Thanks for extra illumination on the matter.

 

And you should also not call UpdateAppTime(), since Framework does that already.

Did not know that either.

 

Well learned a lot here today. :) thx again

Link to comment
Share on other sites

I think I have an issue. In c# I used:

 

            //rotation by mouse
           int mx = Leadwerks.Graphics.Width / 2;
           int my = Leadwerks.Graphics.Height / 2;
           dx = Leadwerks.Math.Curve((Leadwerks.Mouse.X - mx) / 4, dx, (float)(3 / Timing.Time));
           dy = Leadwerks.Math.Curve((Leadwerks.Mouse.Y - my) / 4, dy, (float)(3 / Timing.Time));

 

I tried to use 0.2 * Timing.Time but I only have a blank screen...

i5 2.7Ghz, GTS 450, 8GB Ram, Win7 x64; Win8 x64

rvlgames.com - my games

RVL Games Facebook Page, YouTube Channel

 

Blitzmax :)

Link to comment
Share on other sites

And what about animation: i cn share my code (probably its not a new for Aggror, but anyway, it can be usefull for others)

 

Inside main loop:

float CurrentTime = AppTime();
_deltaTime = (CurrentTime - _elapsedTime) * 0.001f;


Inside animation loop:

_desiredAnimationFPS = _weaponAnimation->GetAnimationSpeed(); 
float dframe = _desiredAnimationFPS * _deltaTime;	
dframe = Clamp(dframe, 0.000, 1.50);
dframe = dframe * ( 1 
	+ 0.6 * (_currentAnimationSegment->getName() == "run")
	+ 0.5 * (_currentAnimationSegment->getName() == "fire"));

 

In this case, if we need to play animation 20 frames per second and we have 40 fps, we would play 0.5 animation frame per game frame. If we would have 20 game fps, animation would be updated by 1 animation frame per game frame.

Working on LeaFAQ :)

Link to comment
Share on other sites

Hey, you're back :P

How is your IK project? You worked on blending, as i remember?

 

It's still ongoing and it's getting closer. I've redone my navmesh code to get rid of opensteer and use the new RVO/steering in recast as it handles crowds better.

 

My character can walk around and place it's feet on the terrain with 80% success. I just need to handle extreme slopes and stairs better.

 

The blending of idle/walk/runs are now fairly smooth with minimal foot sliding.

 

There's still plenty of work to be done and it all comes down to how much time I can find. I crashed my rally car this weekend so I need to spend time on repairing that :(

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...