I've reworked the usage of the character controller. It is now flexible and customizable. Some values are still hardcoded and docs are missing, but the
core system is stable.
The CCT is now detached from a specific entity and doesn't modify the camera, so it can be used for NPCs as well.

Usage for a simple third person player:
Code:
action player_func()
{
	// Allow only one player!
	if(proc_status(player_func) > 1)
	{
		error("Only one player can be active at a time!");
		return;
	}
	
	my->z += 8; // Lift player up a little to prevent falling through ground
	
	// Setup the camera
	cam_target(me); // Focus the player
	cam_mouse_speed(25); // Set a fast mouse.
	cam_basic_offset(vector(0, 0, 20)); // We want a camera focus a little bit above the player
	cam_3person_offset(vector(-250, -30, 0)); // We want to camera to be behind 
	cam_set_mode(CAMERA_THIRD_PERSON); // Enable third person camera
	
	// Setup the CCT
	CCT *cct = cct_create(my.x, vector(10, 16, 46));
	while(1)
	{
		cam_update(); // Update the camera each frame
		my->pan = camera->pan; // We sync the entity rotation with the camera
		
		// Setup the cct input
		cct_set_input(cct, CCT_FORWARD, key_w - key_s);
		cct_set_input(cct, CCT_SIDEWARD, key_a - key_d);
		cct_set_input(cct, CCT_JUMP, key_space);
		cct_set_input(cct, CCT_CRAWL, key_ctrl);
		cct_set_input(cct, CCT_SPRINT, key_shift);
		cct_set_rotation(cct, my->pan);
		cct_update(cct); // Update the character controller
		
		cct_get_position(cct, &my->x); // Get the position of the character
		
		wait(1);
	}
}


Last edited by MasterQ32; 07/30/13 21:11.

Visit my site: www.masterq32.de