[BEHAVIOR] Chipmunk Physics

  • Waltuo , I would just use chipmunk to create the platform movement. It's not that difficult to setup if you understand how chipmunk works. If you can get it working with chipmunk, you'll be more knowledgeable on how to use it for other things, etc.

    here's a gif of something I'm working on that shows a basic platform movement using only chipmunk: http://i.imgur.com/vtWs7Ch.gif

    An important step is to disable friction on the player while moving it, and then reset the friction when move input is released (and also when player is on the ground; you need a way to check if it is or not).

  • R0J0hound , I'm trying to create an elevator. I'm trying to make the elevator not receive any forces from other objects when they touch, so that the force I apply on the elevator is the only force influencing the movement. Any ideas on how to accomplish this?

  • Prominent

    You could try giving the elevator a mass of infinity and just set it's velocity.

    Alternatively you could use joints to emulate how an actual elevator is built. Maybe a groove joint with distance joint that you adjust the length of.

  • R0J0hound , I tried setting the mass to Infinity, but it causes errors related to collision stuff. I'm not sure why.

    I also thought about using joints, but I'm not sure if it would work the way I want it to.. I was going to see if I could add some action to discard the effects of a collision on a chosen object, but wasn't sure where to start. Is that something even possible?

  • Prominent

    Hmm, I think I had to work around that infinity mass issue elsewhere. So scratch that for now.

    Maybe we could do something in post collide. You can get the impulse of the collision with an expression, so maybe you could apply an opposite impulse to negate the force.

  • R0J0hound , post collide only triggers once I think when it first collides, but if the player is standing on the elevator, the elevator would need to continuously negate the forces pushing down on it. I tried anyways, but elevator just gets pushed down.

    I also tried the foreach collision pair, and seeing if I could negate forces, but didn't have any success with that.

    I've also tried using another object to position the elevator to as a way to keep the elevator from moving, but then it causes objects to sink into it. I assume because it is still getting pushed but the position becomes reset.

    :

    edit: also, another reason not to use joints is if the elevator must change direction while moving.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you R0J0hound and Prominent . I'll try and compare both methods, but I think you're probably right and going physics all the way is the best way to go. I'm new to Chipmunk Physics so it's all quite intimidating and I will need to find good tutorials / examples to get started, but if I can get it to work it should help fix a couple of other problems I'm currently facing with my game idea. Thanks again!

  • Prominent

    Waltuo

    I posted this a few pages back, might be useful: https://dl.dropboxusercontent.com/u/523 ... pe_v2.capx

    The elevator/moving platform thing, i just did that by giving it a high mass & directly setting velocity, there didn't seem to be any problems with deflection on impact, & when it stops moving it's set to immovable.

  • mattb That looks great and will no doubt help me in understanding how to use physics instead of platform behavior in my project! I will definitely be studying this, thank you!

  • The elevator/moving platform thing, i just did that by giving it a high mass & directly setting velocity, there didn't seem to be any problems with deflection on impact, & when it stops moving it's set to immovable.

    That method places limitations on what I can do. I'm trying to find a solution that maintains all the physics qualities but can cancel out forces from specific objects.

  • R0J0hound , I just noticed that if both objects colliding have prevent rotation set to Yes, the collisionImpactX and Y always return 0.

  • Prominent

    Here's an idea using collision layers. The idea is the elevator is two different objects on different layers so they don't interact. So for example the orange blocks can affect the elevators motion, whereas the blue one thinks it has high mass.

    https://dl.dropboxusercontent.com/u/542 ... ator2.capx

    Outside of that idea more of chipmunk's collision handlers would need to be exposed. Then maybe tricks like setting the mass high temporarily before the collision is resolved and then setting it back afterwards could be used.

  • R0J0hound , ah! thanks. I was able to apply those concepts to my project, and it's working now!

    Just curious though if you know, why would the collisionImpactY return 0 if rotations are prevented?

  • Prominent

    Not sure. All prevent rotation really does is give the object super high rotational inertia.

  • Once again, R0J0Hound dishing out the tasty treats. Thanks for the great behaviour!

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