|
Correct jumping code :
#416068
01/27/13 19:29
01/27/13 19:29
|
Joined: Apr 2008
Posts: 2,488
ratchet
OP
Expert
|
OP
Expert
Joined: Apr 2008
Posts: 2,488
|
I have a third view camera and player working. But what i need now is the C_trace part containing some jumping code. I've copy and past AUM 97 code from the FPS template, but the code is buggy. I had the player jump to infinity or somtimes do incredible little jumps. So if someone would have a bit of jumping code that works perfectly i would find that great
|
|
|
Re: Correct jumping code :
[Re: ratchet]
#416076
01/27/13 21:36
01/27/13 21:36
|
Joined: Apr 2008
Posts: 2,488
ratchet
OP
Expert
|
OP
Expert
Joined: Apr 2008
Posts: 2,488
|
I found it AUM56 : Ninja Code. It's a WDL code And it contains so much stuff i don't need in the code ... I'll have to adapt it. Argrgrgrhrhrh !!
Last edited by ratchet; 01/27/13 21:52.
|
|
|
Re: Correct jumping code :
[Re: 3run]
#416080
01/27/13 21:53
01/27/13 21:53
|
Joined: Apr 2008
Posts: 2,488
ratchet
OP
Expert
|
OP
Expert
Joined: Apr 2008
Posts: 2,488
|
I made it in 5 minutes with another 3D engine : 3DGS is not for non programmers, but searching on AUM i think i should get the right code !
Last edited by ratchet; 01/27/13 22:19.
|
|
|
Re: Correct jumping code :
[Re: ratchet]
#416084
01/27/13 22:27
01/27/13 22:27
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
I could create a very simple movement script just with some minimal stuff, but you'll still have to do adjustments and implement the features that you need.
POTATO-MAN saves the day! - Random
|
|
|
Re: Correct jumping code :
[Re: ratchet]
#416087
01/27/13 23:46
01/27/13 23:46
|
Joined: Nov 2007
Posts: 2,568 Germany, BW, Stuttgart
MasterQ32
Expert
|
Expert
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
|
Here you go! Save it to a file, include it and adjust the values, tps_controller is your action WASD + Shift + Space are the controls, mouse to rotate
var mouse_speed = 4;
var walking_speed = 6;
var running_speed = 10;
var gravity_force = 2;
var jump_strength = 10;
var feet_height = 40;
var anim_walk_speed = 5;
var anim_stand_speed = 5;
action tps_controller()
{
wait(1);
c_updatehull(me, 1);
var gravity = 0;
var lks = 0;
while(me)
{
my.pan += mouse_speed * mouse_force.x;
VECTOR mov;
mov.x = key_w - key_s;
mov.y = key_a - key_d;
mov.z = 0;
if(key_shift)
vec_normalize(mov, running_speed * time_step);
else
vec_normalize(mov, walking_speed * time_step);
if(vec_length(mov) > 0)
{
ent_animate(me, "walk", total_ticks * anim_walk_speed, ANM_CYCLE); // Adopt animation speed and name
}
else
{
ent_animate(me, "stand", total_ticks * anim_stand_speed, ANM_CYCLE); // Adopt animation speed and name
}
if(key_space != lks)
{
if(key_space)
gravity = jump_strength;
lks = key_space;
}
gravity -= gravity_force * time_step;
move_friction = 0;
c_move(me, mov, vector(0, 0, gravity * time_step), GLIDE | IGNORE_PASSABLE | IGNORE_PASSENTS);
if(c_trace(my.x, vector(my.x, my.y, my.z - feet_height), IGNORE_ME | IGNORE_PASSABLE | IGNORE_PASSENTS | USE_POLYGON))
{
my.z = target.z + feet_height;
gravity = 0;
}
vec_set(camera.x, vector(-150, 0, 50)); // Camera offset
vec_rotate(camera.x, my.pan);
vec_add(camera.x, my.x);
camera.pan = my.pan;
camera.tilt = -15; // Adjust this
wait(1);
}
}
|
|
|
Re: Correct jumping code :
[Re: MasterQ32]
#416136
01/28/13 08:38
01/28/13 08:38
|
Joined: Apr 2008
Posts: 2,488
ratchet
OP
Expert
|
OP
Expert
Joined: Apr 2008
Posts: 2,488
|
thanks a lot It seems to be another new version of code i didn't seen. I'll try that.
|
|
|
|