Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (VoroneTZ, monk12, Quad), 829 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Creating camera view toggle 1st person to 3rd person #376427
07/02/11 20:54
07/02/11 20:54
Joined: Jun 2008
Posts: 37
Oklahoma City, OK
emo10001 Offline OP
Newbie
emo10001  Offline OP
Newbie

Joined: Jun 2008
Posts: 37
Oklahoma City, OK
Hey everyone,

I've been experimenting with what I was hoping would be a simple camera toggle between 3rd person and 1st person point of view. The functionality seems to work. It switches between the 2 views, but after I switch the first time...my pan starts to look shaky and stutters. Any thoughts?

Here's the function:

Code:
function camera_follow(ENTITY* ent)
{	
	var camx = -150;
	var camy = 10;
	var camz = 50;
	var camtilt = -13;
	
//	var camx;
//	var camy;
//	var camz;
//	var camtilt;
		
	while(1)
	{

		if(key_9)
		{
			camx = -150;
			camy = 10;
			camz = 50;
			camtilt = -13;
		}
		if(key_0)
		{
			camx = 5;
			camy = 0;
			camz = 5;
			camtilt = 0;
		}
			
		vec_set(camera.x,vector(camx,camy,camz));  // camera position relative to the player    
		vec_rotate(camera.x,ent.pan); // rotate the camera position with the player
		vec_add(camera.x,ent.x);      // add player position
		vec_set(camera.pan,vector(ent.pan,camtilt,0)); // look in player direction, slighty down 
		wait(1);	
	}
}




"To one who has faith, no explanation is necessary. To one without faith, no explanation is possible." - St. Thomas Aquinas
Re: Creating camera view toggle 1st person to 3rd person [Re: emo10001] #376441
07/02/11 23:30
07/02/11 23:30
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
at a guess it'll be because you have the function running twice?

Re: Creating camera view toggle 1st person to 3rd person [Re: MrGuest] #376464
07/03/11 04:45
07/03/11 04:45
Joined: Jun 2008
Posts: 37
Oklahoma City, OK
emo10001 Offline OP
Newbie
emo10001  Offline OP
Newbie

Joined: Jun 2008
Posts: 37
Oklahoma City, OK
I think I know what you mean, but even if I do it like this it makes no difference:

Code:
function camera_follow(ENTITY* ent)
{		
	var camx;
	var camy;
	var camz;
	var camtilt;
	
	proc_mode = PROC_EARLY;
		
	while(1)
	{
		if(key_9)
		{
			camx = -150;
			camy = 10;
			camz = 50;
			camtilt = -13;
		}
		if(key_0)
		{
			camx = 5;
			camy = 0;
			camz = 5;
			camtilt = 0;
		}
			
		vec_set(camera.x,vector(camx,camy,camz));  // camera position relative to the player    
		vec_rotate(camera.x,ent.pan); // rotate the camera position with the player
		vec_add(camera.x,ent.x);      // add player position
		vec_set(camera.pan,vector(ent.pan,camtilt,0)); // look in player direction, slighty down 
		wait(1);	
	}
}



Is that what you're talking about?


"To one who has faith, no explanation is necessary. To one without faith, no explanation is possible." - St. Thomas Aquinas
Re: Creating camera view toggle 1st person to 3rd person [Re: emo10001] #376536
07/04/11 05:32
07/04/11 05:32
Joined: Jun 2008
Posts: 37
Oklahoma City, OK
emo10001 Offline OP
Newbie
emo10001  Offline OP
Newbie

Joined: Jun 2008
Posts: 37
Oklahoma City, OK
Well I've made a discovery...the shaky part only happens after I've switched from 3rd person to 1st, and then back to 3rd. Then..at that point...if I switch back to 1st person and then back to 3rd person REALLY fast 1 time....it goes away.

But I'd rather not have to tell my players to do that LOL!

I'm hoping I can get this working...seems like a nice way to do camera perspective switching in just one camera function.

Anybody got anymore ideas?


"To one who has faith, no explanation is necessary. To one without faith, no explanation is possible." - St. Thomas Aquinas
Re: Creating camera view toggle 1st person to 3rd person [Re: emo10001] #376559
07/04/11 12:37
07/04/11 12:37
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Where do you call camera_follow?


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Creating camera view toggle 1st person to 3rd person [Re: Superku] #376572
07/04/11 14:49
07/04/11 14:49
Joined: Jun 2008
Posts: 37
Oklahoma City, OK
emo10001 Offline OP
Newbie
emo10001  Offline OP
Newbie

Joined: Jun 2008
Posts: 37
Oklahoma City, OK
I call it in my player_move() code as:

camera_follow(me);

It's the first line in the player_move() section.


"To one who has faith, no explanation is necessary. To one without faith, no explanation is possible." - St. Thomas Aquinas
Re: Creating camera view toggle 1st person to 3rd person [Re: emo10001] #376719
07/06/11 04:45
07/06/11 04:45
Joined: Jun 2008
Posts: 37
Oklahoma City, OK
emo10001 Offline OP
Newbie
emo10001  Offline OP
Newbie

Joined: Jun 2008
Posts: 37
Oklahoma City, OK
Any thoughts? I'm kind of stuck... blush


"To one who has faith, no explanation is necessary. To one without faith, no explanation is possible." - St. Thomas Aquinas
Re: Creating camera view toggle 1st person to 3rd person [Re: emo10001] #376743
07/06/11 10:45
07/06/11 10:45
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Use a different key than key_0 because 0 toggles the camera movement that is included in debug.c, or set "on_0 = NULL;" one frame after game start or don't include debug.c at all.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: Creating camera view toggle 1st person to 3rd person [Re: Superku] #376855
07/07/11 03:57
07/07/11 03:57
Joined: Jun 2008
Posts: 37
Oklahoma City, OK
emo10001 Offline OP
Newbie
emo10001  Offline OP
Newbie

Joined: Jun 2008
Posts: 37
Oklahoma City, OK
Thanks for the advice Superku, but that didn't make any difference either. I think the function and the "if then" statement just didn't sit to well together (at least for camera functions). I broke out each camera as it's own function and then call them from another function...and the shaky/jittery camera has stopped.

Here's what I wound up doing:

Code:
function camera_1stperson()
{
	while(1)
	{
	   camera.x = my.x + 11 * cos(my.pan);
	   camera.y = my.y + 11 * sin(my.pan);
	   camera.z = my.z + 25;
	   camera.pan = my.pan;
	   camera.tilt = 0;
	   camera.roll = 0;
	   wait(1);
    }
}

function camera_3rdperson()
{
	while(1)
	{
	   camera.x = my.x - 150 * cos(my.pan);
	   camera.y = my.y - 150 * sin(my.pan);
	   camera.z = my.z + 50;
	   camera.pan = my.pan;
	   camera.tilt = -13;
	   camera.roll = 0;
	   wait(1);
        }
}
function camera_3rdperson2()
{
	while(1)
	{
	   camera.x = my.x - 250 * cos(my.pan);
	   camera.y = my.y - 250 * sin(my.pan);
	   camera.z = my.z + 200;
	   camera.pan = my.pan;
	   camera.tilt = -25;
	   camera.roll = 0;
	   wait(1);
        }
}

function select_cameras()
{
	
	while(1)
	{
		if(key_7)
		{camera_1stperson();}
		if(key_8)
		{camera_3rdperson();}
		if(key_9)
		{camera_3rdperson2();}
		wait(1);
	}
}



Last edited by emo10001; 07/07/11 04:00.

"To one who has faith, no explanation is necessary. To one without faith, no explanation is possible." - St. Thomas Aquinas
Re: Creating camera view toggle 1st person to 3rd person [Re: emo10001] #376883
07/07/11 11:09
07/07/11 11:09
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
That's not a good solution, every time you press a key, a new while loop starts and the old camera_Xstperson-loops never stop.
If-statements are fine with camera functions, why should they make any problems?

My advice: Return to your old code, use debug-features (don't forget DEBUG_VAR, diag_var, ...), reduce the code to a minimum until you isolate the problem.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
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