ArcBasicDocs
3DPhysics CharactersArcBasic extension

CharacterWalk

Sets how fast a character walks, in units a second.

CharacterWalk ( entity,x#,z#[,relative] )

Parameters

entity
a character (see EntityCharacter)
x#
speed sideways, in units a second. Positive is to the right
z#
speed forwards, in units a second. Negative walks backwards
relative (optional)
True (the default): x# and z# follow the way the character faces. False: they are world directions

Description

Sets how fast a character walks. It keeps walking at that speed during every UpdateWorld until you change it, so set it to 0,0 to stop. The speed is the same however the character is scaled.

The character slides along walls rather than stopping dead, climbs steps no higher than the step height given to EntityCharacter and walks up slopes no steeper than its slope limit.

Example

CharacterWalk.absOpen in editor
; Physics characters example (an ArcBasic extension); A character that walks, jumps, climbs steps and slopes and pushes crates.; Arrows: walk and turn   Space: jump   P: push harderGraphics3D 640,480SetBuffer BackBuffer()light=CreateLight()RotateEntity light,50,30,0ground=CreatePlane()EntityColor ground,70,90,70EntityPhysics ground,1; stairs: each step a quarter of a unit higher than the lastFor i=1 To 4	s=CreateCube()	ScaleEntity s,1.5,i*.125,1	PositionEntity s,-5,i*.125,3+i*2	EntityColor s,150,150,170	EntityPhysics s,1Next; a gentle ramp and one too steep to walk upramp=CreateCube()ScaleEntity ramp,1.5,.1,4PositionEntity ramp,0,1.2,6RotateEntity ramp,-20,0,0EntityColor ramp,170,140,100EntityPhysics ramp,1steep=CreateCube()ScaleEntity steep,1.5,.1,3PositionEntity steep,5,1.4,5RotateEntity steep,-60,0,0EntityColor steep,200,90,80EntityPhysics steep,1; crates to push aboutFor i=0 To 5	c=CreateCube()	ScaleEntity c,.4,.4,.4	PositionEntity c,-3+i*1.2,.4,-4	EntityColor c,200,160,90	EntityPhysics c,2,.5Next; the hero: a pivot at its feet carrying a body and a nose that shows which way it faceshero=CreatePivot()body=CreateCylinder(16,True,hero)ScaleEntity body,.4,.9,.4PositionEntity body,0,.9,0EntityColor body,90,160,255nose=CreateCube(hero)ScaleEntity nose,.12,.12,.25PositionEntity nose,0,1.5,.45EntityCharacter hero,.4,1.8,.3,45camera=CreateCamera(hero)PositionEntity camera,0,4,-8TurnEntity camera,20,0,0push#=1While Not KeyHit(1)	If KeyDown(203) Then TurnEntity hero,0,3,0	If KeyDown(205) Then TurnEntity hero,0,-3,0	speed#=0	If KeyDown(200) Then speed=4	If KeyDown(208) Then speed=-2	CharacterWalk hero,0,speed	If KeyHit(57) Then CharacterJump hero,6	If KeyHit(25) Then push=4-push : CharacterPush hero,push	UpdateWorld	RenderWorld	Text 0,0,"Arrows: walk and turn   Space: jump   P: push harder"	If CharacterOnFloor(hero) Then floor$="on the floor" Else floor$="in the air"	Text 0,15,"The hero is "+floor$+"   push strength "+push	FlipWendEnd

See also