Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,633 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Can c_trace and scan_texture work for a physics entity? #214589
07/05/08 15:51
07/05/08 15:51
Joined: Sep 2006
Posts: 36
Tempe, AZ
B
bpc31 Offline OP
Newbie
bpc31  Offline OP
Newbie
B

Joined: Sep 2006
Posts: 36
Tempe, AZ
I'm using the following code but the add_laps never gets triggered:

action boat
{
player = me;
phent_settype(my, PH_RIGID, PH_BOX);
ph_setgravity( earth_gravity );
phent_setmass(my, 70, PH_POLY);
phent_setfriction(my,0);
phent_setelasticity(my, 25, 1);
phent_setdamping(my, 90, 90);

while(1)
{
phent_getvelocity(my, velocity3, nullvector);
velocity = vec_length(velocity3);

if(key_cuu == 1)
{
vec_set(temp.x, my); vec_normalize(temp, 450000);
phent_addforcelocal(my, temp, nullvector);fire();
}

if(key_cud == 1)
{
vec_set(temp.x, my); vec_normalize(temp, -25000);
phent_addforcelocal(my, temp, nullvector);
}

if(key_cul == 1 && velocity > 60)
{
phent_addtorqueglobal (my, vector(0, 0, 4000));
}

if(key_cur == 1 && velocity > 60)
{
phent_addtorqueglobal (my, vector(0, 0, -6000));
}

c_trace (temp.x, my, scan_texture|ignore_me);

if (str_cmpi (tex_name, "checker1"))
{
add_laps();
}

boat_camera();
wait(1);
}
}

Re: Can c_trace and scan_texture work for a physics entity? [Re: bpc31] #214694
07/06/08 14:36
07/06/08 14:36
Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
kasimir Offline
Senior Member
kasimir  Offline
Senior Member

Joined: Dec 2005
Posts: 490
Germany/Berlin-Velten
Hi add this:

Code:
vec_set (temp.x, my.x);
temp.z -= 100;
c_trace (my.x, temp.x, scan_texture|ignore_me);


does "add_laps" use somethink to check when your leave the checker-texture? else your have tousands of laps when touching this texture!

Last edited by kasimir; 07/06/08 14:40.
Re: Can c_trace and scan_texture work for a physics entity? [Re: kasimir] #214895
07/08/08 01:54
07/08/08 01:54
Joined: Dec 2005
Posts: 116
T
tD_Datura_v Offline
Member
tD_Datura_v  Offline
Member
T

Joined: Dec 2005
Posts: 116
Code:
var ph_nForceX = 450000;  // a bit high?
var ph_nForceXn = -25000;
var ph_nForceY = 4000;  
var ph_nForceYn = -6000;
var ph_vForce[3];
STRING lapTx_s = "checker1";

var ct_nMode  = 0;
var ct_nDown = 5;  // * entity height

function phf_force(_nX, _nY, _nZ) {
	ph_vForce.x = _nX;
	ph_vForce.y = _nY;
	ph_vForce.z = _nZ;
}
action boat {
	player = me;
	phent_settype(me, PH_RIGID, PH_BOX);
	ph_setgravity( earth_gravity );
	phent_setmass(my, 70, PH_POLY);
	phent_setfriction(me, 0);		// ERROR??? NO FRICTION?
	phent_setelasticity(my, 25, 1);
	phent_setdamping(my, 90, 90);

	var bLapped; bLapped = 0;
	while(me != NULL) {
		phent_getvelocity(my, velocity3, nullvector);
		velocity = vec_length(velocity3);

		vec_set(temp, nullvector);
		if(key_cuu == 1) {
			//vec_set(temp.x, my);  // ERROR???  // set v to e, temp, my.x
			//vec_normalize(temp, 450000);  // a bit high?
			phf_force(ph_nForceX, 0, 0);
			phent_addforcelocal(me, ph_vForce, nullvector);
			fire();
		}

		if(key_cud == 1) {
			//vec_set(temp.x, my);  // ERROR???  // set v to e, temp, my.x
			phf_force(ph_nForceXn, 0, 0);
			phent_addforcelocal(me, ph_vForce, nullvector);
		}

		if(key_cul == 1 && velocity > 60) {
			phf_force(0, 0, ph_nForceY);
			phent_addtorqueglobal (me, ph_vForce);
			// does angular damping slow it down
		}

		if(key_cur == 1 && velocity > 60) {
			phf_force(0, 0, ph_nForceYn);
			phent_addtorqueglobal (me, ph_vForce);
		}

		vec_set(temp, my.x);
		temp.z -= ((my.max_z - my.min_z) * ct_nDown);
		ct_nMode = IGNORE_ME | SCAN_TEXTURE | IGNORE_PASSABLE;
		c_trace (my.x, temp, ct_nMode);	// just temp, temp.x not needed

		// that won't stop cheating
		if (str_cmpi (tex_name, lapTx_s)) {
			if (bLapped == 0) {
				add_laps();
				error("add_laps()");
			}
			bLapped = 1;
		} else {
			bLapped = 0;
		}

		boat_camera();
		wait(1);
	}
}

Of course, don't bother with that. It's useless.




Re: Can c_trace and scan_texture work for a physics entity? [Re: tD_Datura_v] #215321
07/10/08 13:54
07/10/08 13:54
Joined: Sep 2006
Posts: 36
Tempe, AZ
B
bpc31 Offline OP
Newbie
bpc31  Offline OP
Newbie
B

Joined: Sep 2006
Posts: 36
Tempe, AZ
Thanks for the updated code!

I still have 2 problems though. My boat model rudder gets stuck on the checker1 texture block (as do my non-physics boats) and I have to set ph_nForceX = 450000 or my model doesn't move very fast. Is that number too high for the physics engine?

Thanks again!
-Bruce


Moderated by  HeelX, Spirit 

Gamestudio download | 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