Just plug it in and load skyline, then script the Character, vehicle or whatever in its Microscript or scene script using these functions.
- Code: Select all
---------------------------------------------------------------------------------
-- Joystick input
---------------------------------------------------------------------------------
function onJSAxisMoved(axis, value)
if(axis==0) then
-- Left Analogue Stick - Up and Down Movements
end
if(axis==1) then
-- Left Analogue Stick - Left and Right Movements
end
sky.print("moving axis: "..axis.." : Value :"..value, 1 );
end
function onJSButtonPressed(button)
sky.print("joystick pressing button button: "..button, 1 );
end
function onJSButtonReleased(button)
sky.print("joystick releasing button button: "..button, 1 );
end
Unfortunately, the base presets such as FPS or vehicle do not work from joystick by default on their actions and will need scripted to get the joystick working.
I think it would be cool to have joystick on the player and cars by default. More fun to play with.
But there are multiple scripted examples to help you get going:
Example 1 - character movement: Royal Sorceress Preset Character.
> Move around using left analogue stick.
> Fire a fireball with the A button.
Preset File: "Asset Library\Presets\Characters\JS - Sourceress.preset"
Tech Demo: "Asset Library\Scenes\Tech Demos\Character\Full Lua Character C3 Joystick enabled.xSkyScene"
Find the player and open the micro script from the properties, look for the joystick functions listed above.
Example 2: - vehicle movement: Porsche Vehicle
This is the one you drive in the Racetrack Template which uses keyboard and joystick.
> Move using left analogue stick
> B button to boost
> Back Right Toggle to accelerate with throttle ratio.
Preset File: "Asset Library\Presets\Vehicles\porche911_Player(JS).preset"
Demo: "Asset Library\Scenes\Templates\Game Templates\03 GameTemplate RaceTrack_V1.xSkyScene".
Find the player car and open the micro script from the properties, look for the joystick functions listed above.