Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
1 registered members (Grant), 999 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
help for newbie (ducking) #316349
03/23/10 15:07
03/23/10 15:07
Joined: Feb 2010
Posts: 886
Random Offline OP
User
Random  Offline 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 Offline
Serious User
darkinferno  Offline
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 Offline OP
User
Random  Offline 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: Random] #317136
03/29/10 14:16
03/29/10 14:16
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
else
{
vec_set(camera.x,vector(player.x,player.y,player.z-20))
}

There is missing a semicolon.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: help for newbie (ducking) [Re: Superku] #317267
03/30/10 12:09
03/30/10 12:09
Joined: Feb 2010
Posts: 886
Random Offline OP
User
Random  Offline 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: Random] #317271
03/30/10 12:22
03/30/10 12:22
Joined: May 2009
Posts: 5,365
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,365
Caucasus
That is so simple man, just make something like this:
Code:
var camera_height = 75;

//in camera script just add camera_height to camera.z
//and call "crawl_" after that
function crawl_()
{
if(key_ctrl)
{
camera_height -= 15* time_step;
}
else
{
camera_height += 15 * time_step;
}
camera_height = clamp(camera_height, 20, 75);




Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: help for newbie (ducking) [Re: Random] #317277
03/30/10 12:27
03/30/10 12:27
Joined: Nov 2006
Posts: 497
Ohio
xbox Offline
Senior Member
xbox  Offline
Senior Member

Joined: Nov 2006
Posts: 497
Ohio
else
{
vec_set(camera.x,vector(player.x,player.y,player.z-20))
}

in this line you must put a semicolon, which is a " ; "
so the new line of code will look like:

vec_set(camera.x, vector(player.x,player.y,player.z-20));

Re: help for newbie (ducking) [Re: xbox] #318159
04/05/10 16:50
04/05/10 16:50
Joined: Feb 2010
Posts: 886
Random Offline OP
User
Random  Offline 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?



Re: help for newbie (ducking) [Re: Random] #318614
04/08/10 18:02
04/08/10 18:02
Joined: May 2009
Posts: 1,816
at my pc (duh)
darkinferno Offline
Serious User
darkinferno  Offline
Serious User

Joined: May 2009
Posts: 1,816
at my pc (duh)
what do u mean by buggy? u cant use words like that, you need to be specific

Re: help for newbie (ducking) [Re: darkinferno] #319006
04/11/10 13:24
04/11/10 13:24
Joined: Aug 2008
Posts: 482
B
bart_the_13th Offline
Senior Member
bart_the_13th  Offline
Senior Member
B

Joined: Aug 2008
Posts: 482
An easiest way is to attach the camera into your models eye position, and just animate the model to crouching(or any position you want) when press 'c'. Nothing more required.


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