|
3 registered members (TipmyPip, VoroneTZ, 1 invisible),
2,073
guests, and 4
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
speed problem
#296903
11/03/09 19:45
11/03/09 19:45
|
Joined: Aug 2008
Posts: 408 mi usa
sadsack
OP
Senior Member
|
OP
Senior Member
Joined: Aug 2008
Posts: 408
mi usa
|
Hello, What I am trying to do, is when you press a key, lets say w, the ship stars moving forward very slowly, every cycle the speed keep going faster. then when you press key s you start slowying slow down. here my code:
#include <acknex.h>
#include <default.c>
////////////////////////////////////////////////////////////////////
ENTITY* player1;
var h_speed = 0;
function act_player1()
{
while(!me){wait(1);}
player1 = me;
me.ambient = 10;
while(me)
{
if (key_w)
h_speed = .01 + .01;
{c_move (me,vecto(h_speed,0,0),nullvector,GLIDE);}
my.pan += 3 * (key_z-key_x) * time_step;
my.tilt += 3 * (key_c-key_v) * time_step;
my.roll += 3 * (key_r-key_t) * time_step;
c_move (me,my.skill1,nullvector,GLIDE);
vec_set(camera.x, vector(player1.x, player1.y, player1.z + 25));
vec_set(camera.pan, player1.pan);
wait(1);
}
}
function main()
{
level_load ("platform.wmb");
wait(2); // wait until the level is loaded
ent_create("ship.mdl",vector(-900,0,150),act_player1);
wait(2); // wait until the level is loaded
}
I should be going up in speed when I press "w". But I am going the same speed all the time. Thank you renny
I have A7 Commercial .............. Now I just need to learn how to use it
|
|
|
Re: speed problem
[Re: sadsack]
#296913
11/03/09 20:17
11/03/09 20:17
|
Joined: Aug 2008
Posts: 408 mi usa
sadsack
OP
Senior Member
|
OP
Senior Member
Joined: Aug 2008
Posts: 408
mi usa
|
Hi, The code that works very good is:
if (key_w)
h_speed = h_speed += 00.01;
{c_move (me,vector( h_speed,0,0),nullvector,GLIDE);}
if (key_s)
h_speed = h_speed -= 00.01;
{c_move (me,vector( h_speed,0,0),nullvector,GLIDE);}
Very smooth speed up and speed down. renny
I have A7 Commercial .............. Now I just need to learn how to use it
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|