How does the Platform Behavior exactly function?

This forum is currently in read-only mode.
From the Asset Store
A pack of 76 platform designs for a platformer game with a mushroom/jungle theme
  • When an object has the Platform Behavior, what exactly do the different variables(Floor Accelaration, Jump Strenght, Fall Gravity, etc.) represent? Is it the number of pixels the object is moved with every frame? What are the exact formulas, that this Behavior uses? How is everything calculated? I need to have more control over objects with this Behavior and experimentation didn't get me far. Now, you might say, that I should just make a custom Gravity Subroutine, but I don't have much time and I would like to make games more quickly. The Behaviors, that come with Construct Classic will help out a lot in this case, but I need to know what they exactly do.

    Thanks!

  • Its pixels per second synced at 60 frames per second.

    Meaning it will vary depending on the frame rate.

    There are no formulas available, unless you can get somebody to dig through the source code.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • There are no formulas available, unless you can get somebody to dig through the source code.

    Source is here if it helps: https://svn.code.sf.net/p/construct/code/Behaviors/Platform/

  • When you click on those parameters in the editor there is a description at the bottom of the property bar that tells what it does. The speeds are in pixels/second and the accelerations are in pixels/second^2, and sustain is in milliseconds as I recall.

    Anyway you'll have to look in the source to see exactly what it does. It also has some other things it handles such as being on a moving platform and such.

    Roughly off the top of my head the motion is done like this. On top of that you'll need to detect collisions and resolve them someway.

    not on ground

    --- add gravity*dt to velocityY

    global number upPressTime=0

    on up pressed

    --- set upPressTime to time

    up is pressed

    time < pressTime+sustain

    --- set velocityY to -jumpStrength

    left is down

    --- subtract acceleration*dt from velocityX

    left is not down

    velocityX < 0

    --- add deceleration*dt to velocityX

    right is down

    --- add acceleration*dt to velocityX

    right is not down

    velocityX > 0

    --- subtract deceleration*dt from velocityX

    every tick

    --- set velocityY to min(velocityY, maxFallSpeed)

    --- set velocityX to clamp(velocityX, -maxSpeed, maxSpeed)

    --- set x to self.x+velocityX*dt

    --- set y to self.y+velocityY*dt

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)