|
2 registered members (TipmyPip, madpower2000),
1,532
guests, and 18
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Problem with Jump/Fall Code [GER/ENG]
[Re: ]
#379141
07/29/11 18:29
07/29/11 18:29
|
Joined: Mar 2008
Posts: 2,247 Baden Württemberg, Germany
Espér
OP
Expert
|
OP
Expert
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
|
tried.. now the landing function isn´t called anymore
Works now.. again.. But sometimes the cube stucks in the ground.. and the other time it floats in the air a bit..
Last edited by Espér; 07/29/11 18:42.
|
|
|
Re: Problem with Jump/Fall Code [GER/ENG]
[Re: Espér]
#379144
07/29/11 19:12
07/29/11 19:12
|
Malice
Unregistered
|
Malice
Unregistered
|
I've looked over it and can't see the problem. Short of having it on my system so I can test it piece by piece there not much more I can say.
I can only think of these possibilities. 1) your movement is being set somewhere else in the code also. Like a gravity function you haven't turned off. 2) your land function is being called more then once. 3) your not ignoring the me entity in the trace for floor distance IGNORE_ME, (but that might be why you use ignore_flags2)
|
|
|
Re: Problem with Jump/Fall Code [GER/ENG]
[Re: ]
#379145
07/29/11 19:17
07/29/11 19:17
|
Joined: Mar 2008
Posts: 2,247 Baden Württemberg, Germany
Espér
OP
Expert
|
OP
Expert
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
|
current code:
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_ME | IGNORE_PASSABLE | IGNORE_FLAG2 | USE_POLYGON);
while(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);
wait(1);
}
//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 | IGNORE_YOU | 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 | IGNORE_YOU | GLIDE);
obj.fallspeed += (obj.gewicht/10.5)*time_step;
obj.jumpkeytrigger = 1;
obj.in_jump = 3;
}
}
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 | IGNORE_YOU | 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 | IGNORE_YOU | 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);
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) && obj.in_jump != 2 && obj.in_jump != 1)
{obj.in_jump = 2;}
}
Last edited by Espér; 07/29/11 19:18.
|
|
|
Re: Problem with Jump/Fall Code [GER/ENG]
[Re: Espér]
#379151
07/29/11 19:33
07/29/11 19:33
|
Malice
Unregistered
|
Malice
Unregistered
|
I'm trying to test your code but got an unknown error for "bulleter" what is it and what should I replace it with?
unknown also gewichtung;
Last edited by Malice; 07/29/11 19:36.
|
|
|
Re: Problem with Jump/Fall Code [GER/ENG]
[Re: Espér]
#379154
07/29/11 19:37
07/29/11 19:37
|
Malice
Unregistered
|
Malice
Unregistered
|
|
|
|
Re: Problem with Jump/Fall Code [GER/ENG]
[Re: ]
#379155
07/29/11 19:40
07/29/11 19:40
|
Joined: Mar 2008
Posts: 2,247 Baden Württemberg, Germany
Espér
OP
Expert
|
OP
Expert
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
|
gewichtung is the weight of an object in kilos.
f.e.
viewdummy = obj_create(NULL, vector(0,0,-40), nullvector, 80, NULL);
create a CUBE_MDL Object at given position with nullvector as rotation, a weight of 80kg and default jumpspeed (50)
viewdummy = obj_create(NULL, vector(0,0,-40), nullvector, 80, 70);
Same, but sets jumpspeed to 70.
|
|
|
Re: Problem with Jump/Fall Code [GER/ENG]
[Re: Espér]
#379158
07/29/11 20:05
07/29/11 20:05
|
Malice
Unregistered
|
Malice
Unregistered
|
Sorry I'm not going to be any help...! I can't even get this code to make the model jump. And I don't know why. Short of getting a clear idea of what you want ant then rewriting it myself I can't help. Sorry but I tried.
|
|
|
Re: Problem with Jump/Fall Code [GER/ENG]
[Re: Espér]
#379161
07/29/11 20:24
07/29/11 20:24
|
Malice
Unregistered
|
Malice
Unregistered
|
I tested your code. and this is whats happening. The land function is entered very late and the while loop in that function is never executed. I'll look to see if I can track it back to the source.
I can't get it to work. The problem I think is in "fallgo" the trace seems not to detect the level and you fall through it. Or gets switch to land late. It's like it's tracing through the ground. I tried replacing the level with a wmb and the level load command, but like with my attempts before it doesn't jump any more once I do that. I'm not sure what the problem is, could it be c_trace???
Last edited by Malice; 07/29/11 21:35.
|
|
|
|