2 registered members (TipmyPip, AndrewAMD),
14,540
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
movement!
#126686
04/26/07 17:12
04/26/07 17:12
|
Joined: Apr 2006
Posts: 160
DerLateinProfi
OP
Member
|
OP
Member
Joined: Apr 2006
Posts: 160
|
Ich habe in einem Tutorial einen Code gefunden nur will ich wissen wie ich dort eine Sprung function einfügen kann. Also auf Space^^ Code:
Entity* player;
view m_camera { layer = 0; pos_x = 0; pos_y = 0; size_x = 1024; //screen res.x size_y = 768; //screen res.y arc = 45; aspect = 1; offset_x = 0; offset_y = 0; ambient = 10; fog = 10; flags = visible; }
action PlayerAct { var move_var; //We're going to use this as our move vector (X,Y,Z) camera.visible = off; //turns off the default camera
while(player != null) //while the player object exists { move_var.x = 0; //resets them all back to 0 move_var.y = 0; //if we don't do thist hen the variables will addup move_var.z = 0; //making the player move faster and faster with no stopping
m_camera.x = player.x - 300 * cos(player.pan); //this will update the cameras position m_camera.y = player.y - 300 * sin(player.pan); m_camera.z = player.z + 150; m_camera.pan = player.pan; m_camera.tilt = -20;
vec_set(temp,my.x); //copies the second vector to the first temp.z -= 8000; //lets make the trace point way way below us
trace_mode = ignore_me+ignore_sprites+ignore_models+use_box; //see manual
result = trace(my.x,temp); if(result > 5) //if from my pos to temp is greater than 5 { move_var.z -= 20; } //fall speed of 20 (higher number, faster falling speed) if(result <= 0) //if from my pos to temp is less than or equal to 0 { move_var.z += 2; } //not touching the floor but extremely close
//Animation Variables my.skill91 += 5*time; //walking/running my.skill92 += 2*time; //for standing still if(my.skill91 >= 100) { my.skill91 = 0; } if(my.skill92 >= 100) { my.skill92 = 0; }
if(key_cuu == on) //if we press the up arrow key { move_var.x = 4; //give the X parameter a value of 4 ent_animate(me,"walk",my.skill91,anm_cycle+anm_add); //walk animation //entity, frame name, percent, mode : see manual } if(key_cud == on) //if we press the down arrow key { ent_animate(me,"walk",my.skill91,anm_cycle+anm_add); //walk animation move_var.x = -4; //give the X parameter a value of 4 } if(key_cul == on) //if we press the left arrow key { my.pan += 4; //add to the pan value } if(key_cur == on) //if we press the right arrow key { my.pan -= 4; //subtract the pan value } while(key_any == 0) { ent_animate(me,"stand",my.skill92,anm_cycle+anm_add); wait(1); } ent_move(move_var,nullvector); //nullvector is a 'blank' vector wait(1); } } Wenn jemand eine Antwort hat, bitte schreiben!^^
MFG: DerLateinProfi
If there's a god
He's watching
can he give a ray of hope
so much pain and so much sorrow
www.lpp1991.de.vu
|
|
|
Re: movement!
[Re: DerLateinProfi]
#126687
04/26/07 17:29
04/26/07 17:29
|
Joined: Jan 2007
Posts: 2,247 Deutsch Niedersachsen
Puppeteer
Expert
|
Expert
Joined: Jan 2007
Posts: 2,247
Deutsch Niedersachsen
|
mit oder ohne aircontrol? EDIT: Wie auch immer  Hier mit: Code:
action PlayerAct { var jump_force; var move_var; //We're going to use this as our move vector (X,Y,Z) var dist_to_ground; camera.visible = off; //turns off the default camera
while(player != null) //while the player object exists { move_var.x = 0; //resets them all back to 0 move_var.y = 0; //if we don't do thist hen the variables will addup move_var.z = 0; //making the player move faster and faster with no stopping dist_to_ground=0; m_camera.x = player.x - 300 * cos(player.pan); //this will update the cameras position m_camera.y = player.y - 300 * sin(player.pan); m_camera.z = player.z + 150; m_camera.pan = player.pan; m_camera.tilt = -20;
vec_set(temp,my.x); //copies the second vector to the first if(jump_force<=0) //nicht beim springen { temp.z -= 8000; //lets make the trace point way way below us trace_mode = ignore_me+ignore_sprites+ignore_models+use_box; //see manual
dist_to_ground = trace(my.x,temp); if(dist_to_ground > 5) //if from my pos to temp is greater than 5 { move_var.z -= 20; } //fall speed of 20 (higher number, faster falling speed) if(dist_to_ground <= 0) //if from my pos to temp is less than or equal to 0 { move_var.z += 2; } //not touching the floor but extremely close } else { temp.z += 8000; trace_mode = ignore_me+ignore_sprites+ignore_models+use_box; //see manual
result = trace(my.x,temp); if(dist_to_ground > 5) //if from my pos to temp is greater than 5 { move_var.z=15*time; //spiel damit rum jump_force-=50*time; //spiel damit rum } else { jump_force=0; } if(dist_to_ground <= 0) //if from my pos to temp is less than or equal to 0 { move_var.z -= 2; } //not touching the floor but extremely close } //Animation Variables my.skill91 += 5*time; //walking/running my.skill92 += 2*time; //for standing still if(my.skill91 >= 100) { my.skill91 = 0; } if(my.skill92 >= 100) { my.skill92 = 0; }
if(key_cuu == on) //if we press the up arrow key { move_var.x = 4; //give the X parameter a value of 4 ent_animate(me,"walk",my.skill91,anm_cycle+anm_add); //walk animation //entity, frame name, percent, mode : see manual } if(key_cud == on) //if we press the down arrow key { ent_animate(me,"walk",my.skill91,anm_cycle+anm_add); //walk animation move_var.x = -4; //give the X parameter a value of 4 } if(key_cul == on) //if we press the left arrow key { my.pan += 4; //add to the pan value } if(key_cur == on) //if we press the right arrow key { my.pan -= 4; //subtract the pan value } if(key_Space&&jump_force<=0&&dist_to_ground<6) { jump_force=200; } while(key_any == 0) { ent_animate(me,"stand",my.skill92,anm_cycle+anm_add); wait(1); } ent_move(move_var,nullvector); //nullvector is a 'blank' vector wait(1); } } Grüße Jannes
Last edited by derOmega; 04/26/07 17:33.
|
|
|
Re: movement!
[Re: Puppeteer]
#126688
04/26/07 17:30
04/26/07 17:30
|
Joined: Apr 2006
Posts: 160
DerLateinProfi
OP
Member
|
OP
Member
Joined: Apr 2006
Posts: 160
|
Also so wie in einem EGO-Shooter!^^
If there's a god
He's watching
can he give a ray of hope
so much pain and so much sorrow
www.lpp1991.de.vu
|
|
|
Re: movement!
[Re: Puppeteer]
#126690
04/26/07 17:40
04/26/07 17:40
|
Joined: Apr 2006
Posts: 160
DerLateinProfi
OP
Member
|
OP
Member
Joined: Apr 2006
Posts: 160
|
Also man soll springen können und dabei wie bei Unreal Turnament sich drehen können. ^^ Ich wollte nur wissen ob das tutorial geht und wie ich da ne sprung funktion reinsetzen soll!^^ Das mit den Animationen ist schon klar!
If there's a god
He's watching
can he give a ray of hope
so much pain and so much sorrow
www.lpp1991.de.vu
|
|
|
Re: movement!
[Re: Puppeteer]
#126692
04/26/07 17:54
04/26/07 17:54
|
Joined: Apr 2006
Posts: 160
DerLateinProfi
OP
Member
|
OP
Member
Joined: Apr 2006
Posts: 160
|
Naja... Ich weiß nicht wo ich den einsetzen soll!^^ (ich noob) Wenn ich in den tamplates alle Includes wegmache und dafür eine einfüge wo der code drinsteht, dann sagt der mir das my.skill und anderes nicht funzt!^^
If there's a god
He's watching
can he give a ray of hope
so much pain and so much sorrow
www.lpp1991.de.vu
|
|
|
Re: movement!
[Re: Puppeteer]
#126694
04/27/07 15:39
04/27/07 15:39
|
Joined: Apr 2006
Posts: 160
DerLateinProfi
OP
Member
|
OP
Member
Joined: Apr 2006
Posts: 160
|
Was herzeigen? Die Fehler oder das Tutorial?
If there's a god
He's watching
can he give a ray of hope
so much pain and so much sorrow
www.lpp1991.de.vu
|
|
|
|