There are several ways you can do this as move is just so a simple character can be scripted in minutes without any advanced math etc... That move function has accompanying functions in both the controller.library() and character.library() to handle strafing and jumping; seen as follows:
- Code: Select all
-- controller library -- dynamic spawned controllers
controller.doStrafe(dccID, speed); -- move left or right depending on minus or positive numbers.
controller.doJump(obj, force);
controller.moveUp(dccID, speed); -- Move up or down based on minus or positive numbers
--character library
character.doStrafe(obj, speed); -- move left or right depending on minus or positive numbers.
character.doJump(obj, force);
character.moveUp(obj, speed); -- Move up or down based on minus or positive numbers
but if you want to override this and do the kinematic bodies movement manually, then you can do this.
- Code: Select all
-- controller code - dynamically spawned controllers
function postInit()
controller.setMoveAdvanced(dccID, 1) -- 1 = true(advanced), 0 = false
end
function onUpdate(td)
controller.setMoveDirection(dccID, dirX, dirY, dirZ);
controller.move(dccID, speed); -- call move to make the new movement direction happen.
end
-- character code - SCC Action
function postInit()
character.setMoveAdvanced(obj, 1) -- 1 = true(advanced), 0 = false
end
function onUpdate(td)
character.setMoveDirection(obj, dirX, dirY, dirZ);
character.move(obj, speed); -- call move to make the new movement direction happen. Negative numbers will make it go backwards.
end
This way, it means you can make the character rotate and look at the player and move the controller in the direction you need.