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
2 registered members (AndrewAMD, Imhotep), 567 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 3 of 3 1 2 3
Re: PH_CHAR [Re: 3run] #397835
03/23/12 22:30
03/23/12 22:30
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline
User
Wjbender  Offline
User
W

Joined: Mar 2012
Posts: 927
cyberspace
made some changes to your code dont know if you would
except the changes but it works,setting the crawl status
i leave up to you because i disabled it during testing
let me know if it works okay..send me your email adress
or may i uplaod it somewhere for you??


Compulsive compiler
Re: PH_CHAR [Re: Wjbender] #397846
03/24/12 07:13
03/24/12 07:13
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Upload it right here, I'm interested.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: PH_CHAR [Re: 3run] #397849
03/24/12 08:58
03/24/12 08:58
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline
User
Wjbender  Offline
User
W

Joined: Mar 2012
Posts: 927
cyberspace
this one uses rigid for crawling
Code:
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
VECTOR move_vec;
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
// camera:
var cam_height = 25;
// crawling:
var crouch_timer = 0;
var crawling = 0;
var allow_stand = 1;
var crawl_old = 0;
// gravity:
var my_height;
var jump_time = 1;
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
ENTITY* c_hull;
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
function handle_crawl()
{
	VECTOR temp;
	vec_set(temp.x, my.x);
	temp.z = my.z + 20; // top point of BBOX
	trace_mode = IGNORE_ME | IGNORE_PASSABLE | USE_BOX;
	c_trace(my.x, temp, trace_mode);	
	draw_line3d(my.x,vector(255,255,255),100);
	draw_line3d(temp,vector(255,255,255),100);
	if(trace_hit)
	{
		allow_stand = 0; 
	}
	else
	{
		allow_stand = 1;
	}
	if(key_ctrl) // if ctrl is pressed
	{
/*		if(crouch_timer > -25)
		{
			crouch_timer -= 5 * time_step;
			if(crouch_timer > 100){crouch_timer = 100;}	
		}
		else
		{
			crawling = 1;
		}
		camera.z += crouch_timer;
*/
		crawling=1;
	}
	else
	{
/*		if(crouch_timer < 0)
		{
			if(allow_stand == 1)
			{
				crawling = 0;
				crouch_timer += 5 * time_step;
				camera.z += crouch_timer;
			}
			else
			{
				camera.z += crouch_timer;
			}
		}
*/
	crawling=0;
	}
}
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
function handle_camera()
{
	camera.pan -= 1 * mickey.x * time_step;
	camera.tilt -= 1 * mickey.y * time_step;
	camera.tilt = clamp(camera.tilt, -90, 90);
	//vec_set(camera.x, vector(my.x, my.y, my.z + cam_height));
	camera.x = my.x + fcos((camera.pan), fcos(camera.tilt, -100));
	camera.y = my.y + fsin((camera.pan), fcos(camera.tilt, -100));
	camera.z = my.z + fsin(camera.tilt, -100);		
	pXent_rotate(c_hull, vector(camera.pan, 0, 0), nullvector);
	// crawling:
	handle_crawl();		
}
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
function apply_gravity()
{
	VECTOR temp;
	VECTOR vec_min;
	vec_set(temp, my.x);
	temp.z -= 1000;
	trace_mode = IGNORE_ME | IGNORE_FLAG2 | IGNORE_PASSABLE | USE_BOX;
	c_trace(my.x, temp, trace_mode); 
	vec_for_min(vec_min, my);
	my_height = my.z + vec_min.z - target.z;			
	if(my_height > 20)
	{
		accelerate(move_vec.z, -6 * time_step, -0.5);
	}
	else
	{
		if(jump_time == 1)
		{
			move_vec.z = -(my_height / 1.2) + 2;
		 	move_vec.z = clamp(move_vec.z, -5, 5);
		}
	}
}
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
action hero()
{
	player = my;
	set(my,TRANSLUCENT);
	set(my,PASSABLE);
	wait(1);
	c_setminmax(my);	
	// create bbox shapes:
	ENTITY* c_stand = ent_create("bbox.mdl", vector(0, 0, -10000), NULL);
	ENTITY* c_crawl = ent_create("bbox.mdl", vector(0, 0, -10000), NULL);
	// scale it down:
	c_crawl.scale_z = 0.5;
	// make them passable and transparent:
	set(c_stand, PASSABLE | TRANSLUCENT);
	set(c_crawl, PASSABLE | TRANSLUCENT);
	// unregistered in physiX:
	pXent_settype(my, 0, 0);
	pXent_enable(my,0);
	// attach all parts:
	c_hull = c_stand;

	vec_set(c_hull.x, my.x);
	vec_set(c_hull.pan, my.pan);
	pXent_settype(c_crawl, 0, 0);
	pXent_settype(c_stand, PH_CHAR, PH_CAPSULE);
	wait(1);
	while(1)
	{
		DEBUG_VAR(crawling, 20);
		vec_set(my.x, c_hull.x);	
		// crawling shape:	
		if(crawl_old != crawling)
		{
			if(crawling == 1)
			{
				c_hull = c_crawl;
				vec_set(c_hull.x, my.x);
				vec_set(c_hull.pan, my.pan);
				pXent_settype(c_stand, 0, 0);
pXent_settype(c_crawl, PH_RIGID, PH_CAPSULE);//***********
pXent_setbodyflag(c_crawl,NX_BF_FROZEN_ROT , 1);//************
			}
			if(crawling == 0)
			{
				c_hull = c_stand;
				vec_set(c_hull.x, my.x);
				vec_set(c_hull.pan, my.pan);
				pXent_settype(c_crawl, 0, 0);
pXent_settype(c_stand, PH_CHAR, PH_CAPSULE);//************
			}
			crawl_old = crawling;
		}
		// movement:		
		if(crawling == 0)
		{
			move_vec.x = 10 * (key_w - key_s) * time_step * (1 + key_shift * 0.5);
			move_vec.y = 10 * (key_a - key_d) * time_step * (1 + key_shift * 0.5);
		}
		else
		{
			move_vec.x = 2 * (key_w - key_s) * time_step;
			move_vec.y = 2 * (key_a - key_d) * time_step;
		} 
		// gravity:
if(!crawling)	apply_gravity();//****************
		// apply all forces:
		pXent_move(c_hull, move_vec, nullvector);		
		// attach camera:
		handle_camera();
		// attach model parts:
		vec_set(c_stand.x, c_hull.x);
		vec_set(c_stand.pan, c_hull.pan);			
		vec_set(c_crawl.x, c_hull.x);
		vec_set(c_crawl.pan, c_hull.pan);			
		// attach visible model:
		vec_set(my.x, c_hull.x);		
		my.pan = camera.pan;
		wait(1);
	}
	// DEATH HERE
}
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////


i dont know how to use code blocks..
your crawl trace vector distance seems to be to short
i did another version wich only used ph_char but then
there seems to be a problem with jumptimer
im sure you will get it fixed the correct way as your controller
already seems very nice .

Last edited by Wjbender; 03/24/12 16:40. Reason: stupidness

Compulsive compiler
Re: PH_CHAR [Re: Wjbender] #397850
03/24/12 09:21
03/24/12 09:21
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Thank you, I'll give it a try. Please use code tags to post scrit next time laugh It'll be easier to read it.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: PH_CHAR [Re: 3run] #397851
03/24/12 10:11
03/24/12 10:11
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline
User
Wjbender  Offline
User
W

Joined: Mar 2012
Posts: 927
cyberspace
Thats what i meant with code block dnt knw how to do it ? And rigid wil cause other problems like friction etc


Compulsive compiler
Re: PH_CHAR [Re: Wjbender] #397863
03/24/12 13:24
03/24/12 13:24
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
["code] insert code here [/code]
* remove " and insert code


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: PH_CHAR [Re: 3run] #397880
03/24/12 16:38
03/24/12 16:38
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline
User
Wjbender  Offline
User
W

Joined: Mar 2012
Posts: 927
cyberspace
cool thanks !


Compulsive compiler
Page 3 of 3 1 2 3

Moderated by  HeelX, Spirit 

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