Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 20:05
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (VoroneTZ, 7th_zorro), 1,332 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Adding player Physics #22752
02/02/04 06:09
02/02/04 06:09
Joined: Jan 2004
Posts: 180
D
Death_By_Games Offline OP
Member
Death_By_Games  Offline OP
Member
D

Joined: Jan 2004
Posts: 180
ok here is what i got:

Code:
 
Action player_walk
{
player = me;
player.healthpoints = 500;
player.items = 0;
player.armour = 20;
player.attack = 30;
str = 35;
while(player.healthpoints > 0)
{
camera.x = player.x - 200*cos(player.pan);
camera.y = player.y - 200*sin(player.pan);
camera.z = player.z + 100;
camera.pan = player.pan;
camera.tilt = -20;
my.pan += 4*(key_a - key_d)*time-20*mouse_force.x*time;
compass += 6*(key_a - key_d)*time-20*mouse_force.x*time;
player_speed.x = 15*(key_w - key_s)*time;
player_speed.y = 0;
player_speed.z = 0;

If((key_w +key_s)!= 0)
{
ent_cycle("walk", my.skill20);
my.skill20 += 4*(key_w - key_s)*time;
my.skill20 %= 100;
}
else
{
if(mouse_left != 1)
{
ent_cycle("stand",my.skill20);
my.skill20 += 2 * time;
my.skill20 %= 100;
}
else
{
If(weapon_equip == 1)
{
ent_vertex(my.sword_tip, 500);
ent_vertex(my.sword_base, 20);
trace_mode = ignore_me + ignore_passable;
trace(my.sword_base, my.sword_tip);
if(result != 0)
{
if(you != null) {you.healthpoints -= 2 * str * time;}
}
ent_cycle("attack", my.skill22);
my.skill22 += 8 * time;

}


}

}
move_mode = ignore_passable;
ent_move(player_speed, nullvector);
wait(1);
}
If(player.healthpoints < 0)
{

death_text.visible = on;
}
}



What is a simple way to add gravity so my player doesnt fly after going down stairs?




If You Program Are You Making Games? Or Is It The World That Makes The Game? Or The Models?? Oh Well... -------------------------------------------------- Im trying to make a game...please help me
Re: Adding player Physics [Re: Death_By_Games] #22753
02/02/04 10:48
02/02/04 10:48
Joined: Aug 2001
Posts: 2,320
Alberta, Canada
William Offline
Expert
William  Offline
Expert

Joined: Aug 2001
Posts: 2,320
Alberta, Canada
Use a trace... First take my.z and minus 2000 from it or so and place that in another vector. Next do a trace to the vector you placed that position in. After that, in an if condition to check if the trace was far from its starting point, if so move the my.z downward until the trace doesnt return such a high value.


Check out Silas. www.kartsilas.com

Hear my band Finding Fire - www.myspace.com/findingfire

Daily dev updates - http://kartsilas.blogspot.com/
Re: Adding player Physics [Re: William] #22754
02/02/04 10:51
02/02/04 10:51
Joined: Jan 2004
Posts: 180
D
Death_By_Games Offline OP
Member
Death_By_Games  Offline OP
Member
D

Joined: Jan 2004
Posts: 180
Ok...i understand about starting my character 2000 caunts lower but why do the trace? I am kinda bad with traces...do you think you could give me a small example?


If You Program Are You Making Games? Or Is It The World That Makes The Game? Or The Models?? Oh Well... -------------------------------------------------- Im trying to make a game...please help me
Re: Adding player Physics [Re: Death_By_Games] #22755
02/02/04 13:09
02/02/04 13:09
Joined: Aug 2001
Posts: 2,320
Alberta, Canada
William Offline
Expert
William  Offline
Expert

Joined: Aug 2001
Posts: 2,320
Alberta, Canada
Heres a commented example for you...

Code:
 

vec_set(temp, my.x); // makes it so temp is always starts at my.x
temp.z -= 4000; // set how far to trace
trace_mode = ignore_me+ignore_sprites+ignore_models; // sets the trace
air = trace(my.x, temp); // see's if player will hit ground sometime

if(air > 3) //if the player is still in the air
{
force = -12 * time; // sets how fast you fall
}

else
{
force = 0; // makes sure you dont fall anymore
}



So just have your player_speed.z value to equal force. Hope that helps


Check out Silas. www.kartsilas.com

Hear my band Finding Fire - www.myspace.com/findingfire

Daily dev updates - http://kartsilas.blogspot.com/
Re: Adding player Physics [Re: William] #22756
02/02/04 20:36
02/02/04 20:36
Joined: Jun 2003
Posts: 143
cologne
Posti_dup1 Offline
Member
Posti_dup1  Offline
Member

Joined: Jun 2003
Posts: 143
cologne
ich hab mal auch ne frage wenn ich mit meiner camera zu nahe eine wand komme kann es passieren das ich durch die wand hindurch schauen kann meine Perspektive ist eine 1st person gab es da nicht einen befehl um sowas zu verhindern?? thx


Es ist besser zu wollen, was man nicht hat, als zu haben, was man nicht will!
Re: Adding player Physics [Re: William] #22757
02/03/04 07:20
02/03/04 07:20
Joined: Jan 2004
Posts: 180
D
Death_By_Games Offline OP
Member
Death_By_Games  Offline OP
Member
D

Joined: Jan 2004
Posts: 180
thanx a bunch, i think i get it =)


If You Program Are You Making Games? Or Is It The World That Makes The Game? Or The Models?? Oh Well... -------------------------------------------------- Im trying to make a game...please help me
Re: Adding player Physics [Re: Death_By_Games] #22758
02/03/04 07:28
02/03/04 07:28
Joined: Jan 2004
Posts: 180
D
Death_By_Games Offline OP
Member
Death_By_Games  Offline OP
Member
D

Joined: Jan 2004
Posts: 180
OK, i added it in with no errors, but i still am not falling:

Code:
  
Action player_walk
{
player = me;
player.healthpoints = 500;
player.items = 0;
player.armour = 20;
player.attack = 30;
str = 35;

while(player.healthpoints > 0)
{
vec_set(temp, my.x); // makes it so temp is always starts at my.x
temp.z -= 4000; // set how far to trace
trace_mode = ignore_me+ignore_sprites+ignore_models; // sets the trace
air = trace(my.x, temp); // see's if player will hit ground sometime
if(air > 3) //if the player is still in the air
{
player_speed = -12 * time; // sets how fast you fall
}
else
{
player_speed = 0; // makes sure you dont fall anymore
}
camera.x = player.x - 200*cos(player.pan);
camera.y = player.y - 200*sin(player.pan);
camera.z = player.z + 100;
camera.pan = player.pan;
camera.tilt = -20;
my.pan += 4*(key_a - key_d)*time-20*mouse_force.x*time;
compass += 6*(key_a - key_d)*time-20*mouse_force.x*time;
player_speed.x = 15*(key_w - key_s)*time;
player_speed.y = 0;
player_speed.z = 0;

If((key_w +key_s)!= 0)
{
ent_cycle("run", my.skill20);
my.skill20 += 8*(key_w - key_s)*time;
my.skill20 %= 100;
}
else
{
if(mouse_right != 1)
{
ent_cycle("stand",my.skill20);
my.skill20 += 2 * time;
my.skill20 %= 100;
}
else
{
If(weapon_equip == 1)
{
ent_vertex(my.sword_tip, 500);
ent_vertex(my.sword_base, 20);
trace_mode = ignore_me + ignore_passable;
trace(my.sword_base, my.sword_tip);
if(result != 0)
{
if(you != null) {you.healthpoints -= 2 * str * time;}
}
ent_cycle("attack", my.skill22);
my.skill22 += 8 * time;

}


}

}
move_mode = ignore_passable;
ent_move(player_speed, nullvector);
wait(1);
}
If(player.healthpoints <= 0)
{
player.healthpoints = -1;
death_text.visible = on;
my.skill22 += 100 * time;
ent_cycle("death", my.skill22);
}
}




If You Program Are You Making Games? Or Is It The World That Makes The Game? Or The Models?? Oh Well... -------------------------------------------------- Im trying to make a game...please help me
Re: Adding player Physics [Re: Death_By_Games] #22759
02/03/04 16:36
02/03/04 16:36
Joined: Jun 2003
Posts: 143
cologne
Posti_dup1 Offline
Member
Posti_dup1  Offline
Member

Joined: Jun 2003
Posts: 143
cologne
hi i have a different script makes its same with yours here i post it maybe it help you the keys are wasd and space for jump but the jump is not so fine it more then a little bit fly

define healt,skill1;
define cam_high,skill5;
define anmprzt,skill20;
define mdl_air,skill21;
define sprghigh,skill22;


var player_speed[3];
var jmp_akt=1;



function jump_control()
{
jmp_akt=0;
waitt(16);
jmp_akt=1;
}



//uses healt,cam_high,anmprzt,sprghigh
Action Spieler
{
var sprakt; // sprunghöhe
var jmp_ergebnis;
player=my;
my.shadow=on;
shift_sense=2;
camera.genius=my;
if (player.healt==0) {player.healt=100;}
if (my.sprghigh == 0 ) {my.sprghigh=30;}
while(player.healt>=0)
{
camera.x=player.x;
camera.y=player.y;
camera.z=player.z+player.cam_high;
player.pan-=20*mouse_force.x*time;
camera.tilt+=20*mouse_force.y*time;
if (camera.tilt > 90) {camera.tilt=90;}
if (camera.tilt < -45) {camera.tilt=-45;}
//camera.tilt %=-90;
camera.pan=player.pan;
//camera.tilt=player.tilt;
player_speed.x = 15*(key_w - key_s)*time;
player_speed.y = 10*(key_a - key_d)*time;
player_speed.z = 0;
if ((key_space==1) && (jmp_akt==1)) //sprungsequenz
{
jump_control();
while(my.sprghigh > sprakt )
{

player_speed.z=10*time;
sprakt+=1;
camera.x=player.x;
camera.y=player.y;
camera.z=player.z+player.cam_high;
player.pan-=20*mouse_force.x*time;
camera.tilt+=20*mouse_force.y*time;
if (camera.tilt > 90) {camera.tilt=90;}
if (camera.tilt < -45) {camera.tilt=-45;}
camera.Pan=player.pan;
camera.tilt=player.tilt;
c_move(my,player_speed,nullvector,ignore_passable+ignore_passents+glide);
wait(1);
}
/*while(sprakt>0)
{
player_speed.z=-10*time;
sprakt+=1;
camera.x=player.x;
camera.y=player.y;
camera.z=player.z+player.cam_high;
player.pan-=20*mouse_force.x*time;
camera.tilt+=20*mouse_force.y*time;
jmp_ergebnis = c_move(my,player_speed,nullvector,ignore_passable+ignore_passents+glide);
if (jmp_ergebnis <=0) { return;}

wait(1);
}*/
sprakt=0;
}
if ((key_W+key_s)!=0)
{
ent_animate(my,"Walk",player.anmprzt,anm_cycle);
player.anmprzt+=4*(key_w - key_s)*time;
player.anmprzt %= 100;
}
else
{
ent_animate(my,"Stand",player.anmprzt,anm_cycle);
player.anmprzt+=2*time;
player.anmprzt %= 100;
}
if ((key_a+key_d)!=0)
{
ent_animate(my,"Walk",player.anmprzt,anm_cycle);
player.anmprzt+=4*(key_a - key_d)*time;
player.anmprzt %= 100;
}
else
{
ent_animate(my,"Stand",player.anmprzt,anm_cycle);
player.anmprzt+=2*time;
player.anmprzt %= 100;
}
vec_set(temp,my.x);
temp.z-=2000;
trace_mode=ignore_me+use_box;
player.mdl_air=trace(my.x,temp);
if (player.mdl_air > 3 )
{
while (player.mdl_air > 3 )
{
player_speed.z=-10*time;
c_move(my,player_speed,nullvector,ignore_passable+ignore_passents+glide);
camera.x=player.x;
camera.y=player.y;
camera.z=player.z+player.cam_high;
camera.Pan=player.pan;
camera.tilt=player.tilt;
player.pan-=20*mouse_force.x*time;
camera.tilt+=20*mouse_force.y*time;
if (camera.tilt > 90) {camera.tilt=90;}
if (camera.tilt < -45) {camera.tilt=-45;}
trace_mode=ignore_me+use_box;
player.mdl_air=trace(my.x,temp);
wait(1);
}
}
else
{
player_speed.z=0;
}
//c_move(my,player_speed,nullvector,ignore_passable+ignore_passents+glide);
move_mode=ignore_passents+ignore_passable;
ent_move(player_speed,Nullvector);

wait(1) ;
}
}


Es ist besser zu wollen, was man nicht hat, als zu haben, was man nicht will!
Re: Adding player Physics [Re: Death_By_Games] #22760
02/06/04 01:53
02/06/04 01:53
Joined: Oct 2002
Posts: 119
Whirabomber Offline
Member
Whirabomber  Offline
Member

Joined: Oct 2002
Posts: 119
Why not just use this:

Code:


var gravity[3] = 0,0,-9.8; // gravity = 9.8 m/s^2 in the negative z direction

..
bunch of code
..

action player_walk
{
..
bunch more code
..

vec_set(temp.x, gravity.x);
temp.z *= time;

ent_move(player_speed, temp);




The above method uses the level collision already being done. When you walk of a ledge, you fall down at 9.8 m/s * time between last frame. It isn't actually acceleration the entity, just moving it 9.8 quants/sec. Probably by combining the trace and the gravity, you could get acceleration due to gravity on some form or another.

Re: Adding player Physics [Re: Whirabomber] #22761
02/06/04 02:12
02/06/04 02:12
Joined: Mar 2001
Posts: 3,298
Beverly, Massachusetts
Rhuarc Offline
Expert
Rhuarc  Offline
Expert

Joined: Mar 2001
Posts: 3,298
Beverly, Massachusetts
3DGS collision has issues with that method last I tried it, you sink halfway into the ground all the time... unless they fixed that. Also, this forum is pretty much for the actual 3dgs physics engine, this would probably be better off in the scripting forum... I think it can be left here for now though.


I no longer post on these forums, keep in touch with me via:
Linkedin.com
My MSDN blog
Page 1 of 2 1 2

Moderated by  HeelX, Spirit 

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