Hi I'm trying to control a Charactor directly using Dark Dynamix
How do I get the player object (which is just a sphere in my example), to rotate and then move forward and backwards along the new rotated axis it seems to only go backwards and forwards along the z axis no matter what way it is facing.
I've also tinkered with the DYN KINEMATIC ON cammand also but this just seems to report that the actor does not exist?
Rem Project: collision test
Rem Created: Monday, January 20, 2014
Rem ***** Main Source File *****
sync on
sync rate 60
autocam off
Global groundID = 1
Global characterID = 2
//-- Gravity for character
Global GRAVITY# = 0.16333 `9.8 / 60
//-- Character variables
Global move# = 0.0
Global strafe# = 0.0
Global xDisplacement# = 0.0
Global yDisplacement# = 0.0
Global zDisplacement# = 0.0
Global collisionFlag = 0
`**********************************************************
make object box groundID,500,10,500
load image "texture.bmp",5
texture object groundID,5
make object sphere characterID,50
load image "me.jpg",6
texture object characterID,6
position object characterID,0,500,0
`********************************************************************
DYN START
DYN SET GRAVITY 0, -9.8 * 10, 0
//-- Set to 1.0 to visualize debug info
DYN SET PARAMETER NX_VISUALIZATION_SCALE, 1.0
DYN SET PARAMETER NX_VISUALIZE_COLLISION_SHAPES, 1.0
DYN MAKE CONTROLLER CAPSULE characterID, object size y(characterID, 1) / 2, 45, 10
//-- Adjust height of controller, the debug renderer does not represent controllers
//-- very well so this is mostly trial and error.
DYN CONTROLLER CAPSULE SET HEIGHT characterID, object size y(characterID, 1) * 0.9
DYN LOAD TRIANGLE MESH "groundID.TMesh", 1
DYN MAKE TRIANGLE MESH groundID, 1
DYN CONTROLLER COLLECT S HITS 1
DYN SIMULATE
`******************************************************************
do
gosub moveplayer
`gosub cameraview
gosub gravity
gosub collisiondetect
DYN FETCH RESULTS
DYN UPDATE
DYN DEBUG RENDER
DYN SIMULATE
sync
loop
`******************************************************************
DYN FETCH RESULTS
DYN STOP
END
`***********************************************************************
moveplayer:
if upkey()=1
zDisplacement#=1
endif
if downkey()=1
zDisplacement#=-1
endif
`********************************** follow view *******************
position camera object POSITION x(characterID),object position y(characterID),object POSITION z(characterID)-100
point camera object position x(characterID),object position y(characterID), object position z(characterID)
Oldplayer1AngleY# = player1AngleY#
Oldplayer1AngleX# = player1AngleX#
player1AngleY# = wrapvalue ( player1AngleY# + mousemovex ( ) * 0.4 )
player1AngleX# = wrapvalue ( player1AngleX# + mousemovey ( ) * 0.4 )
yrotate object characterID,curveangle( player1AngleY#,Oldplayer1AngleY#, 24 )
xrotate camera curveangle ( player1AngleX#, Oldplayer1AngleX#, 24 )
`**************************************************************************************
DYN CONTROLLER MOVE characterID, xDisplacement#, yDisplacement#, zDisplacement#
zDisplacement#=0
return
collisiondetect:
//-- This command returns information on whether the controller is touching anything
collisionFlag = DYN CONTROLLER MOVE(characterID, xDisplacement#, yDisplacement#, zDisplacement#)
return
cameraview:
set camera to object orientation characterID
pitch camera down 45
position camera object position x(characterID), object position y(characterID) + 20, object position z(characterID)
move camera -100
return
gravity:
//-- Up/Down
onGround = collisionFlag && NXCC_COLLISION_DOWN
//-- Gravity
if onGround
yDisplacement# = 0.0
else
yDisplacement# = yDisplacement# - GRAVITY#
endif
return
"There are no perfect ideas only perfect intentions"