Yea, I didn't want to give up on the physics, so I tried again. Turned out, he was walking in the mesh, because I was using an offset that was unneeded.
No, I have the spherecast movement code remarked out.
Physics code that is causing the bouncey movement. If I lower the walk velocity it causes less of a bouncey movement
load3dmap()
function load3dmap()
floortexID = LoadImage( "/media/ground.png" )
SetImageWrapU( floorTexID, 0 )
SetImageWrapV( floorTexID, 0 )
floorBoxID = CreateObjectBox(1000,12,1000)
SetObjectImage( floorBoxID, floorTexID, 0 )
SetObjectLightMode( floorBoxID, 1 )
SetObjectPosition( floorBoxID, 0.0, 0.0, 0.0 )
//SetObjectCollisionMode(floorBoxID,0)
Create3DPhysicsStaticBody(floorBoxID)
SetObjectShapeBox(floorBoxID)
endfunction
loadcharacters()
CreateCharacterController( game.player.objID )
Stand3DPhysicsCharacterController( game.player.objID )
Set3DPhysicsCharacterControllerStepHeight( game.player.objID,12.0 )
Set3DPhysicsCharacterControllerJumpSpeed( game.player.objID, 6.0 )
do
if Get3DPhysicsCharacterControllerExists( game.player.objID )
CharacterControllerInput( game.player.objID )
endif
//PrintC()
//movehero(game.player.objID)
SetCameraLookAt(1, GetObjectX(game.player.objID),GetObjectY(game.player.objID),GetObjectZ(game.player.objID),0)
SetCameraPosition(1, GetObjectX(game.player.objID),GetObjectY(game.player.objID)+12,GetObjectZ(game.player.objID)-25)
//z-axis is making it very bouncey
Step3DPhysicsWorld()
Sync()
loop
function CreateCharacterController( objID as integer )
characterOffsetVec = CreateVector3( 0.0, 0.0, 0.0 )
objectOrientationVec = CreateVector3( 0.0, 0.0, -1.0 )
Create3DPhysicsCharacterController( objID, 1, characterOffsetVec, objectOrientationVec, 0.75 )
DeleteVector3( characterOffsetVec )
DeleteVector3( objectOrientationVec )
rotationInc = 1.0
WalkVelocity = 10.0
RunVelocity = 140.0
endfunction
function CharacterControllerInput( objID as integer )
if GetKeyboardExists()
//Stops movement when no key is pressed.
Move3DPhysicsCharacterController( objID, 0, WalkVelocity )
//W Key Forwards
if GetRawKeyState( 87 )
Move3DPhysicsCharacterController( objID, 1, WalkVelocity )
endif
endif
endfunction
Here is the spherecast if you wanted to see why I can't test a hit on my "hero". But it works when I test the "ground".
function movehero(objID as integer)
//W Key Forwards
if GetRawKeyState( 87 )
MoveObjectlocalZ(objID, -.185)
move_z# = -.185
endif
if GetRawKeyState ( 65 )
RotateObjectGlobalY(objID, -5)
endif
if GetRawKeyState ( 68 )
RotateObjectGlobalY(objID, 5)
endif
if GetRawKeyState( 83 )
MoveObjectLocalZ(objID, .055)
move_z# = .055
endif
gravity# = -1
radius# = 2
object_x# = GetObjectX(objID)
object_y# = GetObjectY(objID)
object_z# = GetObjectZ(objID)
object_oldx# = GetObjectX(objID)
object_oldy# = GetObjectY(objID)
object_oldz# = GetObjectZ(objID)
object_hit = ObjectSphereSlide(floorBoxID, object_oldx#, object_oldy#,object_oldz#,object_x#, object_y#,object_z#,radius#)
if object_hit = 0
MoveObjectLocalY(objID, gravity#)
endif
PrintC(object_hit)
endfunction
Thank you, Stab.