5 self.velocity = movelib_vdrag(self.velocity,0.02,0.5);
\r
7 vector movelib_drag(float drag, float exp)
\r
11 lspeed = vlen(self.velocity);
\r
12 ldrag = lspeed * drag;
\r
13 ldrag = ldrag * drag * exp;
\r
14 ldrag = 1 - (ldrag / lspeed);
\r
16 return self.velocity * ldrag;
\r
21 self.velocity = movelib_vdrag(somespeed,0.01,0.7);
\r
23 float movelib_dragflt(float fspeed,float drag,float exp)
\r
27 ldrag = fspeed * drag;
\r
28 ldrag = ldrag * ldrag * exp;
\r
29 ldrag = 1 - (ldrag / fspeed);
\r
35 Do a inertia simulation based on velocity.
\r
36 Basicaly, this allows you to simulate objects loss steering with speed.
\r
37 self.velocity = movelib_inertia_fromspeed(self.velocity,newvel,1000,0.1,0.9);
\r
39 vector movelib_inertmove_byspeed(vector vel_new, float vel_max,float newmin,float oldmax)
\r
43 influense = vlen(self.velocity) * (1 / vel_max);
\r
45 influense = bound(newmin,influense,oldmax);
\r
47 return (vel_new * (1 - influense)) + (self.velocity * influense);
\r
50 vector movelib_inertmove(vector new_vel,float new_bias)
\r
52 return new_vel * new_bias + self.velocity * (1-new_bias);
\r
57 Applies absolute force to a velocity
\r
59 vector movelib_accelerate(vector vel,float force)
\r
61 return normalize(vel) * (vlen(vel) + force);
\r
63 vector movelib_decelerate(vector vel,float force)
\r
65 return normalize(vel) * (vlen(vel) - force);
\r
68 vector movelib_velocity_transfer(entity source,entity destination)
\r