pXent_movechar(ENTITY* entity, VECTOR* vPos, ANGLE* aRot, var jump); |
With this Function you can move/rotate a character controller (special Actor), that was created with pXent_settype( entity, PH_CHAR, PH_BOX or PH_CAPSULE). The jump value defines the height of your jump, NULL for no jumping.
Parameters: |
entity |
registered Entity pointer ( character controller ) |
Vpos |
vector that moves the character (offset vector) |
aRot |
angle that rotates the character (default: nullvector) |
jump |
let the character jump; the value defines the height. |
Returns: |
1 if successful, 0 otherwise.
Remarks: |
You have to call pXent_settype( entity, PH_CHAR, 0) before you call pXent_movechar(entity, vector, 0).
The character controller can't collide with the PH_PLANE Actor ( falls through ). You can only walk on a terrain or static bodies.
Speed: |
Fast
...
pXent_settype(
entity, PH_CHAR, PH_CAPSULE);
...
move_char();
}
...
function move_char() { if(!character)return; pFocus=character; VECTOR* mov = vector(0,0,0); var jump=0; if(key_space)jump=80; if(key_w)mov.x= 8; if(key_s)mov.x=-8; if(key_a)mov.y= 8; if(key_d)mov.y=-8; vec_rotate(mov,camera.pan); mov.z=0; // must be set, because vec_rotate sets mov.z when the camera looks up/down. pXent_movechar(character, mov, nullvector, jump); }