ent_move (vector reldist, vector absdist);

Moves the my entity over a certain distance, and performs a collision detection during the movement (see the entity chapter about collision detection). The first vector reldist gives a relative distance and direction in rotated entity coordinates, i.e. the direction that the entity is facing. The second vector absdist gives an absolute distance and direction in world coordinates. The resulting movement is a combination of both distances. Normally the first vector is used for the propelling speed of the entity, and the second one for external forces, like gravity and drift. To zero one of these vectors the predefined nullvector can be given.

Ent_move returns the amount of distance covered. If the entity could not move at all due to being blocked by obstacles, it returns a negative value or 0. The predefined MY_SPEED vector is set to the resulting absolute distance. If the entity collided with something, the NORMAL vector is set to the colliding surface's normal - that is a vector of length 1, pointing perpendicularly away from the surface. It can be used to determine the surface orientation. For instance, if NORMAL.Z is near 1, the entity collided with the ground; if NORMAL.Z is near -1, it collided with the ceiling; if NORMAL.Z is near 0, it hit a vertical wall. The surface of a sprite or model entity is considered a vertical cylinder here. The predefined BOUNCE vector is set to the direction into which the colliding entity would bounce off the surface, and thus could be used to implement a bouncing behavior.


reldist distance and direction vector in entity coordinates
absdist distance and direction vector in world coordinates
move_friction predefined variable, friction for gliding along surfaces, 0..1
move_mode predefined variable, collision mode


> 0 distance covered
<= 0 entity could not move


my_speed covered distance and direction
normal Normal vector of hit polygon
bounce Bounce vector of hit polygon
in_passable 1 if the motion ends in a passable block
in_solid 1 if the movement ends in a non passable block
event_type set to type of event


Before doing ent_move, the move mode must be set through the predefined move_mode variable before. The following move mode combinations are available:
IGNORE_YOU ignores the YOU entity on collision detection
IGNORE_PASSABLE ignores all passable blocks and entities
IGNORE_PASSENTS ignores passable model and sprite entities
IGNORE_MAPS ignores all map entities
IGNORE_MODELS ignores all models
IGNORE_SPRITES ignores all sprites
IGNORE_PUSH moves over all entities with lower push values than my
ACTIVATE_TRIGGER enables trigger events during the move
GLIDE glides along walls and entities on impact

The ignore_passents mode can still detect passable blocks and map entities - if the move ended up inside a passable block, the predefined IN_PASSABLE variable is set to 1. If the move ended up inside a solid block (which only can happen if PASSABLE entities are moved), the IN_SOLID variable is set to 1.

On collision, ent_move can trigger collision events on the moving as well as on other entities. If glide is activated, ent_move will itself try to move as far as possible by gliding along surfaces or making way around obstacles. The move_friction variable (range 0..1, default 0.25) determines the friction for gliding along surfaces. At 0 there is no friction at all, at 1 the entity sticks to the surface and does not glide at all.




Ignoring the YOU entity can be used to prevent that a bullet gets stuck immediately within the barrel or within the entity which fired it. The move modes can be combined by simple adding, like this:
result = ent_move (reldist, absdist);

See also:

move_friction, normal, bounce, in_passable, in_solid, event_type, you, c_move► latest version online