Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by Zheka. 06/20/24 14:26
Lapsa's very own thread
by rki. 06/19/24 11:27
A simple game ...
by VoroneTZ. 06/18/24 10:50
Face player all the time ...
by bbn1982. 06/18/24 10:25
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (RealSerious3D, rvl), 1,187 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
squik, AemStones, LucasJoshua, Baklazhan, Hanky27
19060 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
need help....serious problem #95843
10/25/06 06:15
10/25/06 06:15
Joined: Aug 2006
Posts: 68
A
alex5801 Offline OP
Junior Member
alex5801  Offline OP
Junior Member
A

Joined: Aug 2006
Posts: 68
problem 1: my camera view start to shacking when i move my mouse y axis to look upwards or downards.
Problem 2: when my character look upwards and i press forward, i start to float upwards
problem 3: when i look downwards and press forward half of the character body will start to stuck in the floor.
problem 4: when i press jump my character keep going upwards and half of the character body stuck in the ceiling and wont come down .
problem 5: when i press shift to let it run, it have no effect and my character cant go up the stair.
problem 6: there is no animation for my character when i move my character, my character just change location but no animation

Code:



var video_mode=7;
var video_depth=32;
var move_vec[3]=0,0,0;
var idle_percent=0;
var walk_percent=0;
var run_percent=0;
var temptilt = 0;
var distance_traced;
var from_vec;
var to_vec;
var ttemp;
Var land_percent = 60;
Var jump_percent = 0;
DEFINE falling,skill30; // 0 for not falling 1 for falling
DEFINE fall_distance,skill31; // distance to fall
DEFINE jumping,skill32;
DEFINE jump_hight,skill33;
DEFINE BATTERY,skill13; //current battery units
DEFINE ARMOR,skill14; //current armor units
DEFINE HEALTH,skill15; //current health units
DEFINE AMMO,skill16; //current ammo units
DEFINE BATTERY_MAX,skill17; // max battery units
DEFINE ARMOR_MAX,skill18; // max armor units
DEFINE HEALTH_MAX,skill19; // max health units
DEFINE AMMO_MAX,skill20; // max ammo units
DEFINE Keys,skill21; //keeps track of what keys have been picked up
DEFINE idle_percent,skill40; // animation frame cycle % values
DEFINE walk_percent,skill41;
DEFINE run_percent,skill42;
DEFINE land_percent,skill43;
DEFINE jump_percent,skill44;
DEFINE temptilt,skill50;
DEFINE Walk_Anm_Speed,skill1; //walk speed . animation walk speed
DEFINE Walk_Anm_Speed,skill1; //walk speed . animation walk speed
DEFINE Run_Anm_Speed,skill2; // int * walkspeed =run speed . animation run speed
DEFINE Strafe_Anm_Speed,skill3; //strafe speed . animation strafe speed
DEFINE Jump_Walk_Run,skill10; // walk/stand jump height . run jump height
DEFINE move_vec_x,skill98; // movement vector uses skills 98 99 and 100
DEFINE move_vec_y,skill99;
DEFINE move_vec_z,skill100;



action display_glass
{
my.alpha = 25;
my.transparent = on;
}

Action dummy_action
{
wait(1);
}

action player_move
{
player = me;
wait(1);
my.falling = 0;
my.jumping = 0;
my.jump_hight = 0;
my.idle_percent = 0;
my.walk_percent = 0;
my.run_percent = 0;
my.land_percent = 60;
my.jump_percent = 0;
my.temptilt = 0;
Camera.genius = player;
shift_sense = int(my.run_anm_speed);

while (player !=NULL)
{
move_vec[0] = (key_w - key_s + key_cuu - key_cud ) * 20 * time; //moving forward and backward
move_vec[1] = (key_a - key_d + key_comma - key_period) * 15 * time; //strafe movements
distance_traced = trace(from_vec,to_vec);
vec_set( temp.x, player.x); // copies player x/y/z/ to the temp vector
ttemp.z -=4000; // we set the temp vector 4000 quants straight down, below the player entity
trace_mode = IGNORE_ME+IGNORE_SPRITES+IGNORE_MODELS+USE_BOX; // like move_mode and ent_move, trace_mode line must be RIGHT before the actual trace instruction
trace(player.x,temp.x); // traces from the player x/y/z to the modified temp x/y/z
My.fall_distance = trace(my.x,temp);
player.tilt-= mouse_force.y * -4 * time;
player.pan -= (mouse_force.x) * 35 * time; //using the mouse to turn left and right
move_mode = IGNORE_YOU + IGNORE_PASSABLE + IGNORE_PUSH + ACTIVATE_TRIGGER + GLIDE; // move mode parameters to avoid sticking on walls and models
player.tilt-= mouse_force.y * -10 * time;
ent_move(move_vec,NULLVECTOR);

// check if jumping
if (my.jumping !=0)
{
jump_handling();
}


fall_handling();
// check if player pressed jump X and isn't already jumping or falling
if (key_space)
{
if(my.jumping == 0 && my.falling == 0 && my.fall_distance <1)
{
my.jumping = 1 + key_shift; // if holding shift key when hit jump means we were running
move_vec.z = 20*time; // starting jump speed velocity
}
}

if (!my.falling&& my.jumping ==0) // if falling = 0 then !falling is = 1, or true that I'm not falling
{
move_vec.x = (key_w - key_s + key_cuu - key_cud ) * int(my.walk_anm_speed) * time; //moving forward and backward
move_vec.y = (key_a - key_d + key_comma - key_period) * 15 * time;//strafe movements
}

If (my.fall_distance >32)
{
my.falling = 1; // now I'm falling
if (move_vec.z > -20*time) // if not falling at maximum fall rate
{
move_vec.z -= .5*time; // then increase my fall rate
}
}
if(my.jumping!=0)// animate jump
{
jump_animate();
}
else
{
if(my.falling == 1)
{
if (my.fall_distance > 32)
{
ent_animate(me,"jump",60,anm_add);
}
else
{
if (int(my.land_percent) !=0 ) // not done with animation yet
{
my.land_percent = (my.land_percent +8*time)%100;
ent_animate(me,"jump",my.land_percent,ANM_ADD); // animate landing
}
if (my.fall_distance < 0) // have I fallen under a surface?
{
move_vec.z = -my.fall_distance*time; // if so, move me back up
}
}
else

// landing animation done
{
my.falling = 0; // we are no longer falling
my.land_percent = 60; // reset land_percent for the next time we might fall
}

}
}



If (move_vec[0] == 0 && move_vec[1] == 0)
{
stand_animate();
}
else
{
if(key_shift)
{
run_animate();
}
}
else

{
walk_animate();
}
/*
vec_set(temp,my.x);
vec_sub(temp,camera.x);
vec_to_angle(camera.pan,temp); // now MY looks at YOU

vec_set (Camera.x,player.x);
camera.z += 40;
camera.pan = player.pan;
camera.tilt =Player.tilt*4*time;
*/

wait(1);
}
}



function main()
{
level_load("Level1.wmb");
wait(2);
}

function jump_handling()
{
if ( (my.jump_hight > int(my.Jump_Walk_Run) && my.jumping == 1) || (my.jumping == 2 && my.jump_hight > (frc(my.Jump_Walk_Run)*100) ) )
{
my.jumping = 0;
my.move_vec_z = 0;
my.jump_hight = 0;
my.jump_percent = 0;
}
else
{
if (my.move_vec_z > 1*time)
{
my.move_vec_z -= .5*time;
my.jump_hight += my.move_vec_z;
}
else
{
my.move_vec_z = 1*time;
my.jump_hight += my.move_vec_z;
}

}
}
function fall_handling()
{
If (my.fall_distance >64 && sign(my.fall_distance) != -1 && my.jumping ==0 )
{
my.falling = 1; // now I'm falling
if (my.move_vec_z > -15*time)
{
my.move_vec_z -= .5*time;
}
}
else
{
if ( my.fall_distance < 64 && my.falling == 0 && my.jumping ==0 ) // keep us on the floor normally
{
my.move_vec_z = -my.fall_distance*time;
}
}
}

function stand_animate()
{
my.idle_percent = (my.idle_percent +5*time)%100;
ent_animate(me,"idle",my.idle_percent,ANM_CYCLE);
}

function walk_animate()
{
my.walk_percent = (my.walk_percent + sign(my.move_vec_x)*(frc(my.walk_anm_speed)*10)*time)%100;
ent_animate(me,"walk",my.walk_percent,ANM_CYCLE);
}

function run_animate()
{
my.run_percent = (my.run_percent + sign(my.move_vec_x)*(frc(my.run_anm_speed)*10)*time)%100;
ent_animate(me,"run",my.run_percent,ANM_CYCLE);
}

function jump_animate()
{
if (my.jump_percent < 50)
{
ent_animate(me,"jump",my.jump_percent,ANM_ADD);
my.jump_percent = (my.jump_percent +8*time)%60; // give some added room here so the jump_percent can get over 50 for our if check
}
}





Re: need help....serious problem [Re: alex5801] #95844
10/25/06 14:49
10/25/06 14:49
Joined: Apr 2004
Posts: 516
USA
Trooper119 Offline
User
Trooper119  Offline
User

Joined: Apr 2004
Posts: 516
USA
Quote:


Code:



var video_mode=7;
var video_depth=32;
var move_vec[3]=0,0,0;
var idle_percent=0;
var walk_percent=0;
var run_percent=0;
var temptilt = 0;
var distance_traced;
var from_vec;
var to_vec;
var ttemp; // I figured this out later in the code, first I would name this so it has a name other people can recognize, also use either temp, or ttemp, not both
Var land_percent = 60;
Var jump_percent = 0;
DEFINE falling,skill30;
DEFINE fall_distance,skill31;
DEFINE jumping,skill32;
DEFINE jump_hight,skill33;
DEFINE BATTERY,skill13;
DEFINE ARMOR,skill14;
DEFINE HEALTH,skill15;
DEFINE AMMO,skill16;
DEFINE BATTERY_MAX,skill17;
DEFINE ARMOR_MAX,skill18;
DEFINE HEALTH_MAX,skill19;
DEFINE AMMO_MAX,skill20;
DEFINE Keys,skill21;
DEFINE idle_percent,skill40;
DEFINE walk_percent,skill41;
DEFINE run_percent,skill42;
DEFINE land_percent,skill43;
DEFINE jump_percent,skill44;
DEFINE temptilt,skill50;
DEFINE Walk_Anm_Speed,skill1;
DEFINE Walk_Anm_Speed,skill1;
DEFINE Run_Anm_Speed,skill2;
DEFINE Strafe_Anm_Speed,skill3;
DEFINE Jump_Walk_Run,skill10;
DEFINE move_vec_x,skill98;
DEFINE move_vec_y,skill99;
DEFINE move_vec_z,skill100;



action display_glass
{
my.alpha = 25;
my.transparent = on;
}

Action dummy_action
{
wait(1);
}

action player_move
{
player = me;
wait(1);
my.falling = 0;
my.jumping = 0;
my.jump_hight = 0;
my.idle_percent = 0;
my.walk_percent = 0;
my.run_percent = 0;
my.land_percent = 60;
my.jump_percent = 0;
my.temptilt = 0;
Camera.genius = player;
shift_sense = int(my.run_anm_speed); //this doesn't do anything as far as I can tell

while (player !=NULL)
{
move_vec[0] = (key_w - key_s + key_cuu - key_cud ) * 20 * time; //if you press the w and up key you move twice as fast
move_vec[1] = (key_a - key_d + key_comma - key_period) * 15 * time; //same problem here
distance_traced = trace(from_vec,to_vec); //I don't see any defined variables going into this, first time through
vec_set( temp.x, player.x);
ttemp.z -=4000; trace_mode = IGNORE_ME+IGNORE_SPRITES+IGNORE_MODELS+USE_BOX; this should only be defined once, at player start, or unless a special event happens trace(player.x,temp.x); use my.x, this really don't matter though, just my.x is a more general use My.fall_distance = trace(my.x,temp); //your setting your fall distance to your origion of your model - you floor's z (your origion commonly isn't at the bottom of your feet, so this shouldn't work)
player.tilt-= mouse_force.y * -4 * time;
player.pan -= (mouse_force.x) * 35 * time;
move_mode = IGNORE_YOU + IGNORE_PASSABLE + IGNORE_PUSH + ACTIVATE_TRIGGER + GLIDE; //define this once at beggining of script, again unless a special event happens
player.tilt-= mouse_force.y * -10 * time;

ent_move(move_vec,NULLVECTOR);

// check if jumping
if (my.jumping !=0)
{
jump_handling();
}


fall_handling(); //this seems a bit ackward, are you always making your character go through a falling stage?
if (key_space)
{
if(my.jumping == 0 && my.falling == 0 && my.fall_distance <1)
{
my.jumping = 1 + key_shift; move_vec.z = 20*time; // you are going up here, make sure later, this value is set to 0, or a negative if you want it to move back down, I definately would not make this a global variable (course global variables can cause a lot of problems so, I'll let you decide on your own) }
}

if (!my.falling&& my.jumping ==0)
{
move_vec.x = (key_w - key_s + key_cuu - key_cud ) * int(my.walk_anm_speed) * time; //same problem as before, but you dont have this my.walk_anm_speed in your previous expression, its a smart idea to have
move_vec.y = (key_a - key_d + key_comma - key_period) * 15 * time;//same problem
}

If (my.fall_distance >32) //this shouldnt be an arbitrary number, use the origion - bottom of the players box to get a decent number for this, this might be your problem for being in the floor
{
my.falling = 1;
if (move_vec.z > -20*time) // you seem to be doing what I suggested here, good {
move_vec.z -= .5*time; // .5 is a small amount is this enough? I have no idea }
}
if(my.jumping!=0)
{
jump_animate();
}
else
{
if(my.falling == 1)
{
if (my.fall_distance > 32) //addressed this twice
{
ent_animate(me,"jump",60,anm_add);
}
else
{
if (int(my.land_percent) !=0 ) // not done with animation yet
{
my.land_percent = (my.land_percent +8*time)%100;
ent_animate(me,"jump",my.land_percent,ANM_ADD); // i'm guessing this all work, i'm not going to look at it
}
if (my.fall_distance < 0) // I've told you about the origion-box bottom already and the trace problem
{
move_vec.z = -my.fall_distance*time; // this is a bad practice, if your fall distance is 0 or below, I would set either your z to 0 if it is 0, or make it so you are teleported to the top of the surface (my.z = traced z value + (origion-box floor) )
}
}
else

{
my.falling = 0;
my.land_percent = 60; }

}
}



If (move_vec[0] == 0 && move_vec[1] == 0)
{
stand_animate();
}
else
{
if(key_shift)
{
run_animate();
}
}
else

{
walk_animate();
}
/* //DON'T USE /*, either take out the code (prefered), or use // before each line, if you use multiple /*, this causes problems
vec_set(temp,my.x);
vec_sub(temp,camera.x);
vec_to_angle(camera.pan,temp); // now MY looks at YOU

vec_set (Camera.x,player.x);
camera.z += 40;
camera.pan = player.pan;
camera.tilt =Player.tilt*4*time;
*/

wait(1);
}
}



function main()
{
level_load("Level1.wmb");
wait(2);
}

function jump_handling()
{
if ( (my.jump_hight > int(my.Jump_Walk_Run) && my.jumping == 1) || (my.jumping == 2 && my.jump_hight > (frc(my.Jump_Walk_Run)*100) ) )// is hight spelled that way, you do it twice? Also why do you keep making int's out of my.jump_walk_run and fractions, if it works, it works, but either make it a double or an int, is my suggestion, although not necessary
{
my.jumping = 0; //if you have a jump handeling and falling functions, why do you have an exception to if the person is not jumping?
my.move_vec_z = 0;
my.jump_hight = 0;
my.jump_percent = 0;
}
else
{
if (my.move_vec_z > 1*time) //why are you using time here, it doesn't seem to have a practical use,and it is always between 0 - 1, so why 1*?
{
my.move_vec_z -= .5*time; // I would return a value to update your vec value for your z movement instead of using a global here
my.jump_hight += my.move_vec_z;
}
else
{
my.move_vec_z = 1*time; my.jump_hight += my.move_vec_z; //I guess I'm just not used to the way your handeling jumping, I guess this could work (havn't reall looked at it), but what I would do is set jump_height to a specific amount, where once you've reached it, your move_vec becomes increasing negative, or negative immediately
}

}
}
function fall_handling()
{
If (my.fall_distance >64 && sign(my.fall_distance) != -1 && my.jumping ==0 ) //again I feel I should mention the fall_distance issue
{
my.falling = 1; // now I'm falling
if (my.move_vec_z > -15*time)
{
my.move_vec_z -= .5*time;
}
}
else
{
if ( my.fall_distance < 64 && my.falling == 0 && my.jumping ==0 ) // I addressed this ealier in the code, do you have a falling and jumping mechanism twice (one in action, and one here? or is it just me?)
{
my.move_vec_z = -my.fall_distance*time;
}
}
}

function stand_animate()
{
my.idle_percent = (my.idle_percent +5*time)%100;
ent_animate(me,"idle",my.idle_percent,ANM_CYCLE);
}

function walk_animate()
{
my.walk_percent = (my.walk_percent + sign(my.move_vec_x)*(frc(my.walk_anm_speed)*10)*time)%100;
ent_animate(me,"walk",my.walk_percent,ANM_CYCLE);
}

function run_animate()
{
my.run_percent = (my.run_percent + sign(my.move_vec_x)*(frc(my.run_anm_speed)*10)*time)%100;
ent_animate(me,"run",my.run_percent,ANM_CYCLE);
}

function jump_animate()
{
if (my.jump_percent < 50)
{
ent_animate(me,"jump",my.jump_percent,ANM_ADD);
my.jump_percent = (my.jump_percent +8*time)%60; // give some added room here so the jump_percent can get over 50 for our if check
}
}








Okay, nice and simple, questions and answer style, 1. Your first problem is your very clearly copy and pasting from many different sources, I suggest you try to recognize what your code does before you impliment it.

Quote:

problem 1: my camera view start to shacking when i move my mouse y axis to look upwards or downards.



I'm pretty sure this is because you have to movement values on the y axis, and both are at different intervals, see above in red there should only be one of these.
Quote:

problem 3: when i look downwards and press forward half of the character body will start to stuck in the floor.
problem 4: when i press jump my character keep going upwards and half of the character body stuck in the ceiling and wont come down .



Your problem is while you have gravity, your force upwards has some strange calculations, make it cut off over a certain jump interval or make the force upward become constant once you press the jump key, but after that, it is continually becoming a decreasing number (until you hit floor, which is then 0), and the reason you are getting stuck is because your collision detection is set up wrong, you need to take into account of where your origion is compared to when you are tracing things, see some of my comments in your code.
Quote:

problem 5: when i press shift to let it run, it have no effect and my character cant go up the stair.



You don't have any change in your speed when your shift key is pressed, make it so when you move if shift key is pressed (= 1) then increase the interval of movement, and if not ( = 0) then have a lower number
Quote:

problem 6: there is no animation for my character when i move my character, my character just change location but no animation



I usually don't mess with animation, try looking at the templates for animation and see how they do it, understand it, and use the manuel to compensate for what you want to do.
Quote:

Problem 2: when my character look upwards and i press forward, i start to float upwards



I'm not sure why you are tilting your whole character when you move the z value, unless your a space ship or something similar, this may be one of the reasons.

EDIT: I just realized this, make sure your animations are going through the loop properly, if they don't they will only animate for one frame, and then stop

Last edited by Trooper119; 10/26/06 13:08.

A clever person solves a problem.
A wise person avoids it.
--Einstein

Currently Codeing: Free Lite-C

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