Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (SBGuy, Quad), 768 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Creating camera view toggle 1st person to 3rd person [Re: Superku] #376918
07/07/11 18:58
07/07/11 18:58

M
Malice
Unregistered
Malice
Unregistered
M



This is similar to what we posted in your other post Other cam post
You needed a cam state var. You can 1) tell the loops in each cam to While(cam_var==x). Or 2) remove the loops in the cam code and call the function from one loop inside select cam, like I did in the linked post above.


Malice

Last edited by Malice; 07/07/11 18:59.
Re: Creating camera view toggle 1st person to 3rd person [Re: ] #376961
07/08/11 03:33
07/08/11 03:33
Joined: Jun 2008
Posts: 37
Oklahoma City, OK
emo10001 Offline OP
Newbie
emo10001  Offline OP
Newbie

Joined: Jun 2008
Posts: 37
Oklahoma City, OK
Superku, that's a good point about the "camera_Xstperson" loop never stopping. That would explain why my camera.tilt was not resetting...and why sometimes...it would just keep getting bigger and bigger as a variable.

And Malice, that's exactly what I needed, a cam STATE variable to "re-set" every time the function switched..

So, with both of your ideas/advice, now I've got this, and it works perfectly! Thanks guys!

Code:
var cam_mode; //global variable

function camera_1stperson()
{
		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 += (key_pgup-key_pgdn)*5*time_step;
	   if(key_home)
	   {camera.tilt = 0;}
	   camera.roll = 0;
}
function camera_3rdperson()
{
	   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 = -15;
	   camera.roll = 0;   
}
function camera_3rdperson2()
{
	   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;
}

function select_cameras()
{	
	while(1)
	{
		if(key_7)
		{
			camera.tilt = 0;                      
			cam_mode = 1;
		}
		if(key_8)
		{cam_mode = 2;}
		if(key_9)
		{cam_mode = 3;}
		
		if(cam_mode ==1)
		{camera_1stperson();}
		if(cam_mode ==2)
		{camera_3rdperson();}
		if(cam_mode ==3)
		{camera_3rdperson2();}
		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] #376978
07/08/11 11:30
07/08/11 11:30
Joined: Oct 2004
Posts: 900
Lgh
rojart Offline
User
rojart  Offline
User

Joined: Oct 2004
Posts: 900
Lgh
Another good advice is to use camera.c library, or learning from it.

Quote:
camera_person(ENTITY*, VECTOR* offset, var factor)
First or third person camera, looks in the same direction as the entity and moves with it with an offset. The factor (0..1) affects the influence of the entity's tilt and roll angle. First person mode is activated with the [F5] key, third person mode with the [F6] key in the camera_startup function.



Regards, Robert

Quote
Everything should be made as simple as possible, but not one bit simpler.
by Albert Einstein

PhysX Preview of Cloth, Fluid and Soft Body

A8.47.1P
Page 2 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