[r67] elasticity overrides velocity

Bugs will be moved here once resolved.

Post » Tue Nov 15, 2011 8:47 pm

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
B
5
G
2
Posts: 11
Reputation: 1,181

Post » Tue Nov 15, 2011 8:51 pm

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.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Tue Nov 15, 2011 9:36 pm

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.
B
5
G
2
Posts: 11
Reputation: 1,181

Post » Tue Nov 15, 2011 9:46 pm

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.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Tue Nov 15, 2011 11:06 pm

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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Thu Nov 17, 2011 1:15 am

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...
B
5
G
2
Posts: 11
Reputation: 1,181


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 3 guests