Platform object simulating LEFT/RIGHT key not firing moving

I’ve an object with the platform object behaviour, not controled by default keys. I simulate the right/left key on it and the object moves.

The problem is that the condition “is jumping” and “on the floor” goes nice but “is moving” is never fired :frowning:

Can you provide a basic example so we can check it? :slight_smile:

Forget it, now runs and I can’t reproduce it. :neutral_face:

Edit: Read next message.

Ok I have discovered how to reproduce it. What I have said but with the time set to, for example 0.1

PS: With a character controller by default the animation goes nice, it goes bad with “simulated key”.
Proyecto.gdg (22 KB)

Yeah, the condition to check if an object is moving fails at low speeds (for example, max speed = 10) or higher speeds with lower time scales (for example, max speed = 150, time scale = 0.2), because the object moves just a bit per frame I guess :frowning:

The code (for web) says:

gdjs.PlatformerObjectRuntimeBehavior.prototype.isMoving = function() { return (this._hasReallyMoved &&this._currentSpeed !== 0) || this._currentJumpSpeed !== 0 || this._currentFallSpeed !== 0; };
Where “this._hasReallyMoved” is calculated as:

this._hasReallyMoved = Math.abs(object.getX()-oldX) >= 1;

So if the speed is sufficiently low to get a displacement < 1 per frame this variable is false, and the condition is false if you aren’t jumping/falling… I think

I’m able to understand how the “bug” happens… Well explained for real!.. Unfortunately I don’t understand “How to solve it”… I’m sorry…
Can someone please explain how to do it (not for web). Would be great!
Greetings :slight_smile:

The only ways to solve it is to increase the speed of the object (or time scale), or to add a feature request on the forum about this limitation.

1 Like

Thanks :see_no_evil:… Ahhh I understand :see_no_evil:
Greetings :slightly_smiling_face::raised_hands:t5:

1 Like