[r67] elasticity overrides velocity

0 favourites
  • 6 posts
  • Sorry if this is not a bug but just me being silly (just starting off with Construct).

    When setting the elasticity of a physics object, it immediately "falls off the sky".

    The capx shows what I mean: the green block is supposed to jump to the left if you hit L (I mean really jump, not this little hops).

    So is this me not understanding the physics thing?

    Tanks a lot,

    Daan

  • I strongly suggest you to read the tutorial about physics basics and then advanced physics.

    Looks like what you want to do is apply an impulse on your character, not set a property.

  • done, but I'm unsure about how this maps to my situation.

    Maybe I should explain why I am trying this in the first place...

    I want the frog to be able to bounce off anything except for when it hits this anything from above (like the ground or a platform hovering in the middle of the layout).

    first I thought about making this a platform behavior but the frog should only jump (i.e. not walk) and I couldn't think of a kind of a good way to get the bouncing left/right/top. Also I want to have the nice parabola movement.

    So applying an impulse seems like the way to go, but how do i prevent the frog from bouncing when hitting something from above?

    First idea would be to "simply" apply an impulse which is inverse to the current velocity when the frog hits something from above.

  • You should check this topic that explains detecting the "above" of surfaces with the platformer behavior.

    It also shows about customizing the controls, this way you could prevent the frog from moving right/left when it is not jumping, but allowing it to give the direction where to jump to.

    That would make it for the movement.

  • The Box2D engine that powers physics doesn't support setting some object properties on-the-fly, like density, friction, elasticity, immovable and some others.

    To get around this the physics engine resets the physics object when you set these properties, effectively replacing it with a new object. That causes it to lose its velocity, though. It's possible to work around it, if the replaced body gets the same velocity as it used to - I'll see if I can fix this for the next build.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • ah, great! Thanks for calrifying that, I'll try to get that workaround working.

    BTW: I also played around with the plaform behavior and now I read your post I am asking myself if a similar situation applies to setting the deceleration at runtime...?

    Kyatric: Thanks for the tips regarding platforme behavior :)

    But I think I'll go with physics for this one, especially after learning a little about impulse and such. As I said I'm only starting off and learning physics seems very appealing :P

    Also I want to have many jumps, meaning pretty much every key from the keyboard will be a "jump key" with different parameters, so the platformer is not per se a better fit than physics I guess...

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