need code for camera

Posted By: foxter888

need code for camera - 10/06/09 15:15

i'm new at lite-c I saw everything about the documentation but it doen'ts explains much about making a camera
can anybody help me in how to make a 3rd person cam?? it doen't really need to rotate just to follow the character
and to please explain me how it works so I can reference from it.
Posted By: sadsack

Re: need code for camera - 10/06/09 16:58

Hi,
Go here and type in the search box 3rd person camera.
I remenber there was some code in the mag. for 3rd per.cam.
I think, I maybe wrong, but from mag. 65 on can be used in lite-c. You should download all the mag. Alot of good stuff in them.
renny grin


http://www.gstools.de/index.php?option=com_content&task=view&id=10&Itemid=54
Posted By: Razoron

Re: need code for camera - 10/06/09 17:00

a code snippet from my script:
Code:
if (key_a-key_d==0)
{
 leftright=0;
}
move = 7*(key_w-key_s)*time_step; //moves the player with [w] [a] [s] [d]
leftright+=key_a*(0.1*time_step);
leftright-=key_d*(0.1*time_step);
if (leftright>1.4)
{
 leftright=1.4;
}
if (leftright<-1.4)
{
 leftright=-1.4;
}
camera.pan += (3*time_step)*leftright;
my.pan=camera.pan;
camera.x = my.x-200*cos(my.pan);
camera.y = my.y-200*sin(my.pan);
camera.z = my.z+100;
camera.tilt += mouse_force.y;
if(camera.tilt < -50) {camera.tilt = -50;}
if(camera.tilt > 20) {camera.tilt = 20;}



my = player
Posted By: Cowabanga

Re: need code for camera - 10/07/09 07:51

Here's a quick one:
Code:
// Put it in the player's action:
while(1)
{
	player.x = camera.x - 50; // Edit this to fit your code
	player.y = camera.y
	player.z = camera.z -  25 // Edit this to fit your code
	player.pan = camera.pan;
	wait(1);
}


Posted By: sadsack

Re: need code for camera - 10/07/09 21:49

try this on for size, it may fit
Code:
#include <acknex.h>
#include <default.c>

ENTITY* player1;




}

function act_player1()
{ 
  
	while(!me){wait(1);}
                player1 = me;
	me.ambient = 10;
	while(me)
	{
		if (key_a || key_cul) {me.pan += 3*time_step;}
			if (key_d || key_cur) {me.pan -= 3*time_step;}
			if (key_w || key_cuu){c_move (me,vector( 5,0,0),nullvector,GLIDE);}
			if (key_q || key_cuu){c_move (me,vector( 60,0,0),nullvector,GLIDE);}
			if (key_s || key_cud){c_move (me,vector( -5,0,0),nullvector,GLIDE);}
			
		wait(1);
	}
}



function main()
{
	level_load ("");
	wait(2);	// wait until the level is loaded
	ent_create("cube.mdl",vector(500,0,0),act_player1);
	
	while(1) {
  vec_set(camera.x,player1.x); 
  vec_set(camera.pan,player1.pan); 
  
  wait(1);
}
}



this is frist person, but just off set the camera from the object for 3rd person.
renny
© 2024 lite-C Forums