PlatformObjects keys with Javascript

How can I manipulate the behavior “PlatformObject” using a javascript code event?
This is what I make but it does not work when I add the action for simulate Keys for movement. I’ve just follow what it is in the wiki docs.
I will appreciate any ideas.

const player = runtimeScene.getObjects(“PlayerGreen”);
const playerHitBoxes = runtimeScene.getObjects(“PlayerHitBox”);
const player1 = player[0];

const platformerBehavior = playerHitBoxes[0].getBehavior(“PlatformerObject”);

if (platformerBehavior.isJumping() || platformerBehavior.isFalling()){
} else if (platformerBehavior.isOnFloor()) {
if (!platformerBehavior.isMoving()) {
} else {

var LEFTKEY = 37;
var RIGHTKEY = 37;
if (runtimeScene.getGame().getInputManager().isKeyPressed(LEFTKEY)) {

} else if (runtimeScene.getGame().getInputManager().isKeyPressed(RIGHTKEY)) {

if (keyboard.isKeyPressed(LEFTKEY)) {
** playerHitBoxes.simulateLeftKey**
//JUMP (?)
** playerHitBoxes._jumpKey = true;

The Platformer Character and Platform Objects are a behavior rather than native events, and may or may not be accessible via Javascript. Others may be able to chime in to confirm.

However, javascript isn’t the first class language in the engine, the event system is, is there a reason why you’re recreating the platformer character events via JS rather than just using those events?

Hi, thanks for the answer.
It is to program the game to connect to devices such as Smartwatchs, that is why I wanted to use the simulate keys on JS events to avoid using the default controls of the PlatformObjects Behavior.

1 Like