1 registered members (henrybane),
1,499
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Problem with Jump/Fall Code [GER/ENG]
[Re: Espér]
#379227
07/30/11 17:06
07/30/11 17:06
|
Malice
Unregistered
|
Malice
Unregistered
|
Well I found part of the problem and solved it. This need to be changed
obj.roofdistframe = c_trace(obj.x, vector(obj.x, obj.y, obj.z-9000), IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
if(obj.in_jump == 2)
{fallstart(obj);}
else if(obj.in_jump == 3)
{fallgo(obj);}
else if(obj.in_jump == 4)
{landing(obj);}
else if(obj.roofdistframe > obj.objekthoehe/2 && obj.in_jump != 2 && obj.in_jump != 1)
{obj.in_jump = 2;}
}
To some thing like this
switch(obj.in_jump)
{
case 2:
fallstart(obj);
break;
case 3:
fallgo(obj);
break;
case 4:
landing(obj);
break;
// default:
// if(obj.roofdistframe > (obj.objekthoehe) && obj.in_jump != 2 && obj.in_jump != 1)
// obj.in_jump = 2;
// break;
}
The comment out line(in my script),in the original script was causing the "states to rapidly repeat. It in effect was staying in "fallgo" at the last condition. This was happening because you never put a case for 0 so when you reached 0 it defaulted to that line (I think). All I know for sure is that it was changing from in_jump=3 to in_jump=4 then right back to in_jump=3. This made it fall through the floor. So That is fixed, with the setting I'm using now it floats above or touches the floor when it lands. It seems to stop at a different point each time. So I'm trying to figure out why. I'll work a little more on it.
|
|
|
Re: Problem with Jump/Fall Code [GER/ENG]
[Re: ]
#379228
07/30/11 17:52
07/30/11 17:52
|
Malice
Unregistered
|
Malice
Unregistered
|
The sinking into the floor and falling through is so simple to solve. Can't believe I didn't see it before. You have IGNORE_YOU set in the c_move, But right before to c_move, c_trace sets the you entity to the floor below it. So the collision system never activates when it touches the floor. so you stop at once 2 "waits" have finished and the code kills the last c_move. REMOVE IGNORE_YOU for the move or set it to some other object. Here it is work fine now...
void landing(ENTITY* obj)
{
obj.fallspeed = obj.fallspeedold;
obj.roofdist = c_trace(obj.x, vector(obj.x, obj.y, obj.z-9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
if(obj.roofdist > (obj.objekthoehe))
{
obj.roofdist = c_trace(obj.x, vector(obj.x, obj.y, obj.z-9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
c_move(obj, vector(0, 0, -(1*(bulleter/100))*time_step), nullvector, GLIDE | IGNORE_PASSABLE | USE_POLYGON);
}
//obj.z += obj.objekthoehe/2;
obj.in_jump = 0;
}
void fallgo(ENTITY* obj)
{
obj.roofdist = c_trace(obj.x, vector(obj.x, obj.y, obj.z-9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
if(obj.roofdist > (obj.objekthoehe))
{
c_move(obj, vector(0, 0, -(obj.fallspeed*(bulleter/100))*time_step), nullvector, IGNORE_FLAG2 | IGNORE_PASSABLE | USE_POLYGON | GLIDE);
obj.fallspeed += (obj.gewicht/10.5)*time_step;
obj.fallspeed = clamp(obj.fallspeed, 0,100);
}
else
{
if(obj.roofdist <= (obj.objekthoehe) && obj.in_jump != 4)
{
obj.in_jump = 4;
}
}
}
void fallstart(ENTITY* obj)
{
obj.jumpspeed = obj.jumpspeedold;
obj.fallspeedold = obj.fallspeed;
obj.roofdist = c_trace(obj.x, vector(obj.x, obj.y, obj.z-9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
if(obj.roofdist > (obj.objekthoehe) && obj.in_jump != 3)
{
c_move(obj, vector(0, 0, -(obj.fallspeed*(bulleter/100))*time_step), nullvector, IGNORE_FLAG2 | IGNORE_PASSABLE | USE_POLYGON | GLIDE);
obj.fallspeed += (obj.gewicht/10.5)*time_step;
obj.jumpkeytrigger = 1;
obj.in_jump = 3;
fallgo(obj);
}
}
void jumpgo(ENTITY* obj)
{
obj.roofdist = c_trace(obj.x, vector(obj.x, obj.y, obj.z+9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
if(obj.roofdist > (obj.objekthoehe) && obj.jumpspeed > 10)
{
c_move(obj, vector(0, 0, (obj.jumpspeed*(bulleter/100))*time_step), nullvector, IGNORE_FLAG2 | IGNORE_PASSABLE | USE_POLYGON | GLIDE);
obj.jumpspeed -= (obj.gewicht/10.5)*time_step;
}
else if(obj.roofdist < (obj.objekthoehe) && obj.in_jump != 2)
{
obj.in_jump = 2;
}
else if(obj.jumpspeed <= 10 && obj.in_jump != 2)
{
obj.in_jump = 2;
}
else
{
obj.in_jump = 2;
}
}
void jumpstart(ENTITY* obj)
{
obj.roofdist = c_trace(obj.x, vector(obj.x, obj.y, obj.z+9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
if(obj.roofdist > (obj.objekthoehe) && obj.in_jump != 1)
{
obj.jumpspeedold = obj.jumpspeed;
c_move(obj, vector(0, 0, (obj.jumpspeed*(bulleter/100))*time_step), nullvector, IGNORE_FLAG2 | IGNORE_PASSABLE | USE_POLYGON | GLIDE);
obj.in_jump = 1;
}
}
//================================================================================================================================================
//================================================================================================================================================
//================================================================================================================================================
void jump_event(ENTITY* obj, var frames, VECTOR* direct, var fall)
{
obj.roofdist = c_trace(obj.x, vector(obj.x, obj.y, obj.z+9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
if(obj.roofdist > obj.objekthoehe/2)
{
obj.jumpspeedold = obj.jumpspeed;
c_move(obj, vector(0, 0, (obj.jumpspeed*(bulleter/100))*time_step), nullvector, IGNORE_FLAG2 | IGNORE_PASSABLE | USE_POLYGON | IGNORE_YOU | GLIDE);
obj.in_jump = 1;
}
while(frames > 0 && obj.in_jump == 1)
{
jumpgo(obj);
c_move(obj, vector((direct.x*(bulleter/100))*time_step, 0, 0), nullvector, GLIDE | IGNORE_PASSABLE | IGNORE_FLAG2);
frames -= 1;
wait(1);
}
obj.roofdistframe = c_trace(obj.x, vector(obj.x, obj.y, obj.z-9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
if(obj.roofdistframe > obj.objekthoehe/2)
{obj.in_jump = 2;}
if(fall == true)
{
while(obj.in_jump != 0 && obj.in_jump != 1)
{
if(obj.in_jump == 2)
{fallstart(obj);}
else if(obj.in_jump == 3)
{fallgo(obj);}
else if(obj.in_jump == 4)
{landing(obj);}
c_move(obj, vector((direct.y*(bulleter/100))*time_step, 0, 0), nullvector, GLIDE | IGNORE_PASSABLE | IGNORE_FLAG2);
wait(1);
}
}
c_move(obj, vector((direct.z*(bulleter/100))*time_step, 0, 0), nullvector, GLIDE | IGNORE_PASSABLE | IGNORE_FLAG2);
}
void jump_player(ENTITY* obj)
{
if(key_space == 1 && obj.jumpkeytrigger == 0)
{
if(obj.in_jump <= 0)
{jumpstart(obj);}
else if(obj.in_jump == 1)
{jumpgo(obj);}
}
else if(key_space == 0 && obj.in_jump == 1)
{obj.in_jump = 2;}
else if(key_space == 0 && obj.jumpkeytrigger == 1)
{obj.jumpkeytrigger = 0;}
obj.roofdistframe = c_trace(obj.x, vector(obj.x, obj.y, obj.z-9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
switch(obj.in_jump)
{
case 2:
fallstart(obj);
break;
case 3:
fallgo(obj);
break;
case 4:
landing(obj);
break;
default:
if(obj.roofdistframe > (obj.objekthoehe) && obj.in_jump != 2 && obj.in_jump != 1)
obj.in_jump = 2;
break;
}
}
As this is done I will delete your project from my system. Good luck on you project.
Last edited by Malice; 07/30/11 18:52.
|
|
|
Re: Problem with Jump/Fall Code [GER/ENG]
[Re: Espér]
#379244
07/30/11 22:00
07/30/11 22:00
|
Malice
Unregistered
|
Malice
Unregistered
|
Ok the line in landing();
if(obj.roofdist > (obj.objekthoehe))
try
if(obj.roofdist >= (obj.objekthoehe))
or
if(obj.roofdist >= (obj.objekthoehe-5))
that might do it.
Last edited by Malice; 07/30/11 22:01.
|
|
|
Re: Problem with Jump/Fall Code [GER/ENG]
[Re: Espér]
#379247
07/30/11 22:16
07/30/11 22:16
|
Malice
Unregistered
|
Malice
Unregistered
|
CHANGE
void landing(ENTITY* obj)
{
obj.fallspeed = obj.fallspeedold;
obj.roofdist = c_trace(obj.x, vector(obj.x, obj.y, obj.z-9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
if(obj.roofdist > (obj.objekthoehe))
{
obj.roofdist = c_trace(obj.x, vector(obj.x, obj.y, obj.z-9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
c_move(obj, vector(0, 0, -(1*(bulleter/100))*time_step), nullvector, GLIDE | IGNORE_PASSABLE | USE_POLYGON);
}
//obj.z += obj.objekthoehe/2;
obj.in_jump = 0;
}
TO
void landing(ENTITY* obj)
{
obj.fallspeed = obj.fallspeedold;
obj.roofdist = c_trace(obj.x, vector(obj.x, obj.y, obj.z-9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
if(obj.roofdist > (obj.objekthoehe/2))
{
obj.roofdist = c_trace(obj.x, vector(obj.x, obj.y, obj.z-9000), IGNORE_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
c_move(obj, vector(0, 0, -(1*(bulleter/100))*time_step), nullvector, GLIDE | IGNORE_PASSABLE | USE_POLYGON);
}
//obj.z += obj.objekthoehe/2;
if(obj.roofdist<= obj.objekthoehe/2)
{
obj.in_jump = 0;
}
}
if that doesn't do it I'm out of ideas. Sorry I did my best!
|
|
|
Re: Problem with Jump/Fall Code [GER/ENG]
[Re: Espér]
#379249
07/30/11 22:21
07/30/11 22:21
|
Malice
Unregistered
|
Malice
Unregistered
|
|
|
|
|