Hi Leaf,
Sorry about delay, been busy with my own stuff.
I compiled a small level to test this out but its been a while since I applied ground based players so everything might not work as indicated.
What the level has is a 'Model' terrain, a player model and a skybox.
As expected, everything works as it should do.
Here is the script and if you want the level, i will put it up to download.
The file is 3mgbs but may not be able to pass thru gmail due to the file holding an .exe.
This may not help you out with your current project but based on your posts, it should.
Its not very well commented but post if you want a comprehensive 'comments'.
Be prepared for a long wait from me, hopefully other users more experienced will be able to help out.
Code:
//Set path to files
path ".\\wdls";
path ".\\models";
path ".\\sounds";
path ".\\images";
path ".\\maps";
string level_str = <leaf.WMB>;
var video_screen = 1;
var enable_polycollision = 1;
var video_mode = 8; //1024*764 Bild
var video_depth = 32; // 32 bit colour D3D mode
var max_entities = 5000;
var tex_share = 1;
var disable_z_glide =1;
var camera_distance = 30;
var camera_height = 8;
var VecTo;
var VecFrom;
var player_distance; // moves the player
var jumping = 0;
define attack skill42;
define strength skill43;
define health = skill18; // just another name for skill18
function player_event();
function player_jumps();
font arial = "arial", 0, 20;
panel debug_pl
{
pos_x = 10; pos_y = 10;
layer = 10;
digits = 5, 5, 3, arial, 16, time_fac;
flags = visible, refresh;
}
sky cube
{
type=<canyons+6.tga>;
layer=2; /// default
//z= 20; //// shifts height, experiment with this value
material=mat_sky; //makes sky brighter
flags=cube,visible;
}
function set_camera()
{
while(1)
{
camera.x = player.x - camera_distance * cos(player.pan);
camera.y = player.y - camera_distance * sin(player.pan);
camera.z = player.z + camera_height;
camera.pan = player.pan;
camera.tilt += 2 * mouse_force.y * time;
wait(1);
}
}
FUNCTION main()
{
level_load(level_str );
wait(4);
sky_clip = -65;
wait(2);
set_camera();
}
action player_me // attached to the player
{
my.fat = on;
my.narrow = on;
c_setminmax(my);
player = me; // I'm the player
player.attack = 30;
player.strength = 200;
my.enable_impact = on;
player.health = 200; // and I have 100 health points
my.event = player_event;
while (my.health > 0)
{
camera.tilt += 10 * mouse_force.y * time;
camera.pan -= 10 * mouse_force.x * time;
my.pan = camera.pan;
my.tilt = camera.tilt;
vec_set (temp, my.x);
temp.z -= 100000;
c_trace(VecFrom.x,VecTo.x,ignore_me+ignore_passable+use_box+activate_sonar);
// trace_mode = ignore_me + ignore_passable + use_box+activate_sonar;
my.skill30 = trace (my.x, temp);
if(result <= 0 )
{
//place player on ground
vec_set(VecFrom,my.x);
vec_set(VecTo,my.x);
VecTo.z -= 80* time; // place player on floor
my.z -= c_trace(VecFrom.x,VecTo.x,ignore_me+ignore_sprites+ignore_passable+ignore_passents+use_box);
my.z += 0.2;
}
player_distance.x = 8 * (key_w - key_s) * time; // moves forward / backward with W / S
player_distance.y = 8 * (key_a - key_d) * time;
player_distance.z = 8 * (key_space - key_c) * time;
c_move(my,player_distance,nullvector,ignore_passable + glide);
if (key_shift ==1 && key_w==1 )
{
player_distance.x = 15 * time;
}
if (jumping == 0)
{
vec_set (temp, my.x);
temp.z -= 10000;
c_trace(VecFrom.x,VecTo.x,ignore_me+ignore_passable+use_box+activate_sonar);
my.skill30 = trace (my.x, temp);
if (my.skill30 < 50) // fall on the ground when closer than 50 quants to the surface
{
player_distance.z = -my.skill30;
}
else // way up in the air?
{
player_distance.z -= 15 * time; // then decrease player's z slowly
}
// player_distance.z = -trace (my.x, temp);
my.skill30 = -trace (my.x, temp);
if ((key_w == 1) || (key_s == 1)) // the player is walking
{
ent_cycle("walk", my.skill20); // play walk frames animation
my.skill20 += 8 * time; // "walk" animation speed
if (my.skill20 > 100) {my.skill20 = 0;} // loop animation
}
else // standing
{
ent_cycle("stand", my.skill21); // play stand frames animation
my.skill21 += 2 * time; // "stand" animation speed
if (my.skill21 > 100) {my.skill21 = 0;} // loop animation
}
if (key_a== 1) // strafe
{
ent_cycle("walk", my.skill20);
my.skill20 += 8 * time; // "walk" animation speed
if (my.skill20 > 100) {my.skill20 = 0;} // loop animation
}
if (key_d== 1) // strafe
{
ent_cycle("walk", my.skill20);
my.skill20 += 8 * time; // "walk" animation speed
if (my.skill20 > 100) {my.skill20 = 0;} // loop animation
}
}
if ((key_space == 1) && (jumping == 0)) // space to jump
{
player_jumps();
}
c_move(my,player_distance,nullvector,ignore_passable + glide);
// move_mode = ignore_passable + ignore_passents + ignore_models + ignore_sprites + glide;
wait (1);
}
}
////////////////////////////////////////////////////////////////////////
function player_jumps()
{
proc_kill(4);
my.skill20 = 0;
jumping = 1;
while (my.skill20 < 95)
{
ent_cycle("jump", my.skill20);
my.skill20 += 3 * time; // "jump" animation speed
// player_distance.x += 2 * time;
if (my.skill20 < 30)
{
player_distance.z += 0.1 * time;
}
else
{
player_distance.z -= 0.1 * time;
}
wait (1);
}
jumping = 0;
}
////////////////////////////////////////////////////////////////////////////////////
function player_event()
{
if (my.health > 0)
{
my.health -= 0.5;
// snd_play (playerhit_snd, 40, 0);
}
}
Action Poly
{
my.polygon = on;
}
Cheers...
and have fun doing this...