Gamestudio Links
Zorro Links
Newest Posts
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
LPDIRECT3DCUBETEXTUR
E9

by Ayumi. 04/12/24 11:00
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
6 registered members (AndrewAMD, ricky_k, EternallyCurious, 7th_zorro, 2 invisible), 477 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
FPS camera movement #458494
03/15/16 14:47
03/15/16 14:47
Joined: Nov 2009
Posts: 201
Logitek Offline OP
Member
Logitek  Offline OP
Member

Joined: Nov 2009
Posts: 201
Hi everybody, another day, another question smile

There were already similar questions on this forum, but I didn't find a real solution. So I will try to ask here.

I have tried to make the FPS camera movement more smoother. If you move the mouse slowly, it is smooth, but if you move the mouse faster to look around, it is not that smooth, often also jittery or it is stuttering. Maybe this is the wrong word for it. It looks like that it is not smooth. FPS is 60. So that is not the problem. And the camera movement instructions are in a proc late function.

I think everybody knows that code already, because it seems to be standard in 3dgs:

Quote:

camera.pan -= mouse_force.x * mousesensitivity;
camera.tilt -= mouse_force.y * mousesensitivity;


I have also tried different ways:

Quote:

camera.pan -= mouse_force.x * mousesensitivity * time_step;
camera.tilt -= mouse_force.y * mousesensitivity * time_step;


or

Quote:

camera.pan -= mouse_force.x * maxv(mousesensitivity, 0.001);
camera.tilt -= mouse_force.y * maxv(mousesensitivity, 0.001);


also with mickey. But it was not the right thing.
The result were better with mouse_force but not perfect.

So maybe anyone else has already found out a better way, or an idea to make the movement of the FPS cam smoother.

Thanks.

Re: FPS camera movement [Re: Logitek] #458496
03/15/16 15:03
03/15/16 15:03
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Hi.

This is what I do for the camera movement:
Code:
var mouseSpeedFac = 1;

camera.pan = cycle(camera.pan - mickey.x / 6.5 * mouseSpeedFac, 0, 360);
camera.tilt = clamp(camera.tilt - mickey.y / 6.5 * mouseSpeedFac, -90, 90);

And it works perfectly for me. I remember this code was given to me by Kartofel, so all credit goes to him. Btw, I would avoid using 'proc_late' for camera, just call it right at the end of the player's movement code's loop (right before 'wait(1)').



Greets


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: FPS camera movement [Re: 3run] #458497
03/15/16 16:30
03/15/16 16:30
Joined: Nov 2009
Posts: 201
Logitek Offline OP
Member
Logitek  Offline OP
Member

Joined: Nov 2009
Posts: 201
Hi, I have made a quick test.
And it seems that this is really the best solution!
I will make some further tests to get sure, because I can't believe that laugh

Thank you and thanks to Kartofel.

Re: FPS camera movement [Re: Logitek] #458498
03/15/16 16:37
03/15/16 16:37
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Quote:
Also don't use 'time_step' with 'mickey' as it's already there.
I don't remember where I heard this, thought it might be wrong (cause example in the manual uses 'time_step'). Anyway I'm glad to help!


Just made a small test, take a look at this code:
Code:
void main(){
	fps_max = 60;
	level_load("");
	wait(3);
	
	ent_create(CUBE_MDL, vector(200, 50, 0), NULL);
	ent_create(CUBE_MDL, vector(200, 0, 0), NULL);
	ent_create(CUBE_MDL, vector(200, -50, 0), NULL);

	while(1){
		
		fps_max = 60;
		if(mouse_right){
			fps_max = 30;
		}
		if(mouse_left){
			fps_max = 512;
		}
		DEBUG_VAR(fps_max, 10);
		
		camera.pan -= mickey.x * time_step; // try without time_step too
		
		wait(1);
	}
}

It can show why it's better to do not use 'time_step' but to allow player to adjust "mouseSpeedFac".


Best regards.

Last edited by 3run; 03/15/16 16:46.

Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: FPS camera movement [Re: 3run] #458500
03/15/16 17:29
03/15/16 17:29
Joined: Nov 2009
Posts: 201
Logitek Offline OP
Member
Logitek  Offline OP
Member

Joined: Nov 2009
Posts: 201
Thanks for the information. Yes, I know mickey is already using time_step. I read that anywhere in the past. After some further tests I can say, it is working great. Better than I thought. For vertical invert I have used

Quote:

camera.tilt = clamp(camera.tilt - mickey.y / 6.5 * mouseSpeedFac, -90, 90);
camera.tilt *= -1;

Re: FPS camera movement [Re: Logitek] #458965
04/11/16 10:30
04/11/16 10:30
Joined: Nov 2009
Posts: 201
Logitek Offline OP
Member
Logitek  Offline OP
Member

Joined: Nov 2009
Posts: 201
Hello. After a lot of tests I have seen that it is running really good with a high framerate. But if the framerate is for example only 30 it is not that smooth anymore. Of course, 30 fps is only the half of 60, that's true. But if you look at tripe A games, they have also no problem with a smooth camera movement at 30 fps. What is their secret? I know, Gamestudio is using the windows mouse driver, as far as I know, but maybe their is another trick, another algorithm?

Re: FPS camera movement [Re: Logitek] #458972
04/11/16 14:17
04/11/16 14:17
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Originally Posted By: Logitek
Hello. After a lot of tests I have seen that it is running really good with a high framerate. But if the framerate is for example only 30 it is not that smooth anymore. Of course, 30 fps is only the half of 60, that's true. But if you look at tripe A games, they have also no problem with a smooth camera movement at 30 fps. What is their secret? I know, Gamestudio is using the windows mouse driver, as far as I know, but maybe their is another trick, another algorithm?
Hi!

It work very smooth for me, independent to framerate (you are doing probably something wrong). I don't have any visual differences between 30-60 fps (as same as the example I posted above).


Best regards


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: FPS camera movement [Re: 3run] #458973
04/11/16 15:21
04/11/16 15:21
Joined: Nov 2009
Posts: 201
Logitek Offline OP
Member
Logitek  Offline OP
Member

Joined: Nov 2009
Posts: 201
Hello. I know, it is the best camera code.

I have tested your example too. And I have tested it now again.

But instead of

camera.pan -= mickey.x;

with the line:

camera.pan = cycle(camera.pan - mickey.x / 6.5 * mouseSpeedFac, 0, 360);


The mouseSpeedFac var is 1

And it does not look that smooth at 30 fps. It is hard to see if you use only the 3 box models. But maybe only my eyes are confuse wink I will recheck my other code stuff.

Re: FPS camera movement [Re: Logitek] #458974
04/11/16 15:33
04/11/16 15:33
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Well, I use this code in all of my projects, so I would notice it. And BTW I'm talking about this example:
Code:
var mouseSpeedFac = 1;

camera.pan = cycle(camera.pan - mickey.x / 6.5 * mouseSpeedFac, 0, 360);
camera.tilt = clamp(camera.tilt - mickey.y / 6.5 * mouseSpeedFac, -90, 90);



Best regards


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: FPS camera movement [Re: 3run] #458975
04/11/16 15:42
04/11/16 15:42
Joined: Nov 2009
Posts: 201
Logitek Offline OP
Member
Logitek  Offline OP
Member

Joined: Nov 2009
Posts: 201
Well. I use this code too. Because it is the best. Maybe it is anything else in my code that is confusing my eyes. But it is also possible that it is my mouse. I will make some further tests.

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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