|
1 registered members (Grant),
999
guests, and 2
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
help for newbie (ducking)
#316349
03/23/10 15:07
03/23/10 15:07
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
Doese anybody know or does anybody can give me an tut or explane me how I can let my player duck when I hold the "c" butten? And not even 3 camera, I just need it in first persional mode. I know I just need to let my player sink into the ground as long I hold the "c" butten, but I dont know how code that, without so much bugs.
I only use lite-c.
sry for my not so good english.
thanks futhermore.
|
|
|
Re: help for newbie (ducking)
[Re: Random]
#316399
03/23/10 20:04
03/23/10 20:04
|
Joined: May 2009
Posts: 1,816 at my pc (duh)
darkinferno
Serious User
|
Serious User
Joined: May 2009
Posts: 1,816
at my pc (duh)
|
you dont push the player into the ground, well that depends, if your character is a entity that floats around then yes you could push it into the ground, if not.. then there are other ways, how do you attach your camera to your player? if all you do is: vec_set(camera.x,player.x) then you could do:
if (!key_c) { vec_set(camera.x,player.x) } else { vec_set(camera.x,vector(player.x,player.y,player.z-20)) //20 is how much the cam will be lowered }
[edit] wrong forum btw
Last edited by darkinferno; 03/23/10 20:05.
|
|
|
Re: help for newbie (ducking)
[Re: darkinferno]
#317116
03/29/10 11:38
03/29/10 11:38
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
Hmmm... I become a syntax error, for a bracked. Here I just show the script (it`s from aum 90, I just writen it alittlebit diffrent). I marked your duck code with red.
var player_speed = 20; var fwdbk_accel = 7; var side_accel = 3; var friction = 1.5; var fallspeed = 1; var jump = 21; var resilience = 4; var disttoground = 64; var camera_h = 12; var camera_h_frict = 0.95; var camera_v = 8; var camera_v_frict = 0.8; int Pl_Cam_vertex = 593;
STRING* key_forward = "w"; STRING* key_backward = "s"; STRING* key_left = "a"; STRING* key_right = "d"; STRING* key_duck = "c"; STRING* key_jump = "space"; STRING* key_run = "shiftl";
action player1() { set (my, INVISIBLE); var forward_on, backward_on, right_on, left_on, duck_on, jump_on, run_on; var camera_h_speed = 0, camera_v_speed = 0, current_height = 0, jump_handle; VECTOR horizontal_speed, vertical_speed, temp; vec_set(horizontal_speed.x, nullvector); vec_set(vertical_speed.x, nullvector); while(1) {
forward_on = 0; backward_on = 0; right_on = 0; left_on = 0; duck_on = 0; jump_on = 0; run_on = 0; if(key_pressed(key_for_str(key_forward))) forward_on = 1; if(key_pressed(key_for_str(key_backward))) backward_on = 1; if(key_pressed(key_for_str(key_left))) left_on = 1; if(key_pressed(key_for_str(key_right))) right_on = 1; if(key_pressed(key_for_str(key_duck))) duck_on = 1; if(key_pressed(key_for_str(key_jump))) jump_on = 1; if(key_pressed(key_for_str(key_run))) run_on = 1;
vec_for_vertex(camera.x,me,Pl_Cam_vertex); camera.pan -= accelerate (camera_h_speed, camera_h * (mouse_force.x), camera_h_frict); camera.tilt += accelerate (camera_v_speed, camera_v * (mouse_force.y), camera_v_frict); my.pan = camera.pan; wait(1);
horizontal_speed.x = (horizontal_speed.x > 0) * maxv(horizontal_speed.x - time_step * friction, 0) + (horizontal_speed.x < 0) * minv(horizontal_speed.x + time_step * friction, 0); if(forward_on) { horizontal_speed.x += time_step * fwdbk_accel; horizontal_speed.x = minv(horizontal_speed.x, time_step * player_speed * (1 + run_on)); } if(backward_on) { horizontal_speed.x -= time_step * fwdbk_accel; horizontal_speed.x = maxv(horizontal_speed.x, -(time_step * player_speed * (1 + run_on))); } horizontal_speed.y = (horizontal_speed.y > 0) * maxv(horizontal_speed.y - time_step * friction, 0) + (horizontal_speed.y < 0) * minv(horizontal_speed.y + time_step * friction, 0); if(left_on) { horizontal_speed.y += time_step * side_accel; horizontal_speed.y = minv(horizontal_speed.y, time_step * player_speed * (1 + run_on)); } if(right_on) { horizontal_speed.y -= time_step * side_accel; horizontal_speed.y = maxv(horizontal_speed.y, -(time_step * player_speed * (1 + run_on))); } if(duck_on) { vec_for_vertex(camera.x,me,Pl_Cam_vertex); } else { vec_set(camera.x,vector(player.x,player.y,player.z-20)) } move_friction = 0; vec_set(temp.x, my.x); temp.z -= 1000; current_height = c_trace(my.x, temp.x, IGNORE_ME | IGNORE_PASSABLE | USE_BOX | GLIDE); if(current_height < (disttoground * 0.97)) { vertical_speed.z = resilience * time_step; } else { if(current_height > disttoground) { vertical_speed.z -= fallspeed * time_step; } else { vertical_speed.z = 0; } } if((jump_on) && (current_height < disttoground)) { vertical_speed.z = jump * time_step; } c_move (my, horizontal_speed.x , vertical_speed.x, IGNORE_PASSABLE | USE_BOX | GLIDE); wait(1); } }
Last edited by Random; 03/29/10 11:42.
|
|
|
Re: help for newbie (ducking)
[Re: Superku]
#317267
03/30/10 12:09
03/30/10 12:09
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
A missing semicolon? Sry when I ask but what is a semicolon? Or can I look it somewere up? Jeh, that will be tha best, becose I whant to lern all this. So is there a way to look all those functions up?
Last edited by Random; 03/30/10 12:10.
|
|
|
Re: help for newbie (ducking)
[Re: xbox]
#318159
04/05/10 16:50
04/05/10 16:50
|
Joined: Feb 2010
Posts: 886
Random
OP
User
|
OP
User
Joined: Feb 2010
Posts: 886
|
if(duck_on) { vec_for_vertex(camera.x,me,Pl_duck_Cam_vertex); } else { vec_for_vertex(camera.x,me,Pl_Cam_vertex); }
That works for me good, but its still buggy. Does anybody know wy?
|
|
|
|