Hi
i would like to know why the capsule for the character is higher than the box (player) ? And how I can fixe that ?
Thanks
(clic on the screen to see the matter)
// Project: test
// Created: 2016-06-16
// set window properties
SetWindowTitle( "test" )
SetWindowSize( 1024, 768, 0 )
// set display properties
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
Create3DPhysicsWorld()
global player=2
global ground = 1
init()
global CameraDistance#=-8
//setcameraposition(1,getobjectx(ground),getobjecty(ground)+10,getobjectz(ground)+CameraDistance#*5)
// setcameralookat(1,getobjectx(ground),getobjecty(ground),getobjectz(ground),0)
u=40
rotationInc = 1
do
if getpointerpressed() or GetRawJoystickButtonPressed(1,1)
jumped=1
Jump3DPhysicsCharacterController(player)
//SetObject3DPhysicslinearVelocity( player, 0, 1, 0,30)
endif
setcameraposition(1,getobjectx(player),getobjecty(player)+120,getobjectz(player)+CameraDistance#*35)
setcameralookat(1,getobjectx(player),getobjecty(player),getobjectz(player),0)
setpointlightposition(1,getobjectx(player),getobjecty(player)+2,getobjectz(player))
Debug3DPhysicsCharacterController(player,1)
joystick_y# = GetRawJoystickY(1)
joystick_x# = GetRawJoystickX(1)
Print(str(joystick_y#)+"/"+str(joystick_x#))
Move3DPhysicsCharacterController(Player,0,0)
if joystick_y#<0
Move3DPhysicsCharacterController(Player,1,u)
endif
if joystick_y#>0
Move3DPhysicsCharacterController(Player,2,u)
endif
if joystick_x#<0
//Move3DPhysicsCharacterController(Player,3,u)
finalRotation = finalRotation - rotationInc
Rotate3DPhysicsCharacterController( Player, finalRotation )
endif
if joystick_x#>0
//Move3DPhysicsCharacterController(Player,4,u)
finalRotation = finalRotation + rotationInc
Rotate3DPhysicsCharacterController( Player, finalRotation )
endif
Print( ScreenFPS() )
Step3DPhysicsWorld()
Sync()
loop
function init()
setclearcolor(0,0,0)
clearscreen()
SetAmbientColor( 20,20,20 )
SetSunActive(1)
CreatePointLight( 1, 0, 0, 0, 35, 255, 0,0 )
//LoadObject(3, "terrain01.b3d")
createobjectbox(ground,1000,1,1000)
setobjectposition(ground,0,0,0)
setobjectcolor(ground,0,255,125,255)
set_physics(ground,1,2)
createobjectbox(player,10,15,10)
setobjectposition(player,0,30,0)
setobjectcolor(player,255,0,0,255)
u=6
//SetObjectScale(player,u,u,u)
Create_character_controller(player)
//SetObjectScale(player,1,1,1)
endfunction
Function Create_character_controller(player)
characterOffsetVec = CreateVector3( getobjectx(player), getobjecty(player),getobjectz(player))
objectOrientationVec = CreateVector3( getobjectx(player), getobjecty(player),getobjectz(player))
Create3DPhysicsCharacterController(player, 1, characterOffsetVec, objectOrientationVec,0.75 )
DeleteVector3(characterOffsetVec)
DeleteVector3(objectOrientationVec)
endfunction
function set_physics(objectnumber,phb,phs)
select phb
case 1
Create3DPhysicsstaticBody(objectnumber)
endcase
case 2
Create3DPhysicsdynamicBody(objectnumber)
endcase
endselect
select phs
case 2
SetObjectShapebox(objectnumber)
endcase
case 1
SetObjectShapeSphere(objectnumber)
endcase
case 3
SetObjectShapeConvexHull(objectnumber)
endcase
endselect
endfunction
AGK2 tier1 - http://www.dracaena-studio.com