1

I'm trying to create this trampoline/rubber band using box2d and cocos2d. I got to a point where in my head it should all just work except I don't get the expected effect. My trampoline looks like this:

enter image description here

  • the green objects and the blue one are static
  • the red dots represent distanceJoints between those objects with the following params:

frequency = 10.0 dampingRatio = 0.1

  • the brown objects have the following properties:

friction = 0.0 restitution = 0.3 density = 20.0

  • the blue object is a static object
  • the green lines represent distanceJoints with the following properties:

frequency = 4.0 dampingRatio = 0.5

  • the properties of the object dropped on the trampoline are these:

fiction = 0.0 restitution = 0.5 density = 100.0

The effect I'm getting using this configuration when I drop the object on the trampoline is more of a mattress drop effect, my object is bounced up once or twice but not by much and than it stops.

My questions are:

  1. Is this a good approach? How can I tweak this trampoline to behave more like a trampoline and less like a mattress?

  2. Once #1 is answered how can I make my blue dummy/ghost object not respond to any collisions and therefore be invisible/non existent as far as the user is concerned?

Thanks!

Horatiu Paraschiv
  • 1,750
  • 2
  • 15
  • 37

1 Answers1

1

If you are getting the desired effect initially but then it fades away, it could be that the damping of the distance joints is just too high. That said, I don't think objects bounce up and down forever on a trampoline in real life...

To make a body be invisible/non existent you can set the fixture to be a sensor fixture, or se the collision filter bits to zero, or just not give it any fixtures in the first place.

iforce2d
  • 8,194
  • 3
  • 29
  • 40
  • Thanks for the response. The problem I have is that the object bounces once but the bounce is very weak so not sure how can I tweak those values so that the initial bounce is bigger (like a strong spring). If I lower the dropped objects' mass than it is not heavy enough to bounce. I will try to not give any fixtures to the blue object. I will lower the dampingRatios and see how things go. any other ideas are welcome. Thanks again for your response. – Horatiu Paraschiv Mar 01 '14 at 01:15
  • This is probably not something that people can advise you very well on, since these kind of settings basically require trial and error and a lot of tweaking values to get right. I would start with a damping ratio of zero, and frequency of about 3, gives me a nice springy effect with a single distance joint. If that does not seem even close, then you probably have a more complex effect going on with the interaction of all those joints together. – iforce2d Mar 01 '14 at 06:22
  • I think you might be better off without the joints underneath. They remind me of the way mattresses are made to isolate movement from one side to another :) whereas you are really trying to represent a single strand of material. If you are familiar with my Box2d editor, you can try this scene with the trial version, it's useful to tweak values like this even if you don't have the full version: http://www.iforce2d.net/trampoline-22102183.rube (in this I have joined each body to the end points, and its neighbors). – iforce2d Mar 01 '14 at 06:48
  • Thanks again for your input, it is much appreciated. Lowering the dampingRatio helped a lot and my object bounces a lot more. The second suggestion of not adding a fixture to the blue body also had the expected effect. I'm not familiar but I'll try your box2d editor just to confirm behaviors. I need the joints underneath to keep my 'trampoline' stiff if I remove them it looks like a loose elastic thing. I'll take a look at your sample though. I'm sure I'll come up with more questions on box2d subjects since I'm only starting to play&learn about it, until then I'll mark this as correct. – Horatiu Paraschiv Mar 02 '14 at 05:36