bounce
Bounce off direction.
When a c_move function generates a collision,
this vector is set to the direction into which the colliding entity would
bounce off the obstacle surface, and can be used to implement a
bouncing behavior.
Type:
VECTOR
Modified by:
c_move
Remarks:
-
Can be modified anytime and thus won't keep its values during wait.
-
Algorithm: bounce = speed + 2*dot(normal,-speed)*normal, while
speed = distance vector to target, normal = target surface normal.
Example:
action bouncer()
{
while(1)
{
c_move(me,vector(5*time_step,0,0),nullvector,0); // move ahead...
if (trace_hit) {
vec_to_angle(my.pan,bounce); // and bounce off any obstacles
}
wait(1);
}
}
See also:
c_move, target, normal
► latest
version online