[BEHAVIOR] Chipmunk Physics

Post your completed addons to share with the community

Post » Sat Feb 20, 2016 6:18 pm

@tucamone
Gravity is global so you could either disable gravity and every tick apply a force to each object so they have their own gravity, or you can leave the gravity on and cancel gravity on so objects by applying a force opposite the direction of gravity on an object's pre step.
B
94
S
33
G
118
Posts: 5,393
Reputation: 75,847

Post » Tue Feb 23, 2016 6:48 pm

I need two things that C2 Box2D can't do and Chipmunk sadly neither, at least it seem that way. I just want to make sure.

1. Setup collision polygon during the gameplay (i.e. by event, programatically).
2. Apply force from multiple points inside the sprite which need to be setup/adjusted during the gameplay, not before.

The reason I need this, is the physics wrapping object that would wrap multiple adjacent squares as one. Moving dozens of joint squares might bring a huge performace issues + it doesn't work as intended anyway. If anybody is interested there i complete question: pin-phys-o-s-together-lego-or-set-img-pts-coll-poly-by-event_t169043

If there is a way to achieve this with the Chipmunk I would really like to hear it. I should have tried that before buying the license =( I thought changing things like image points or collision polygons via events is the natural thing to do.
B
6
Posts: 14
Reputation: 278

Post » Tue Feb 23, 2016 8:21 pm

@mh11
1.
The collision polygon isn't something the C2 usually lets you do, and the behavior just grabs from that. The only plugin i know of that let's you change the collision polygon is yann's polygon plugin, but I haven't tested it recently to see if it works well with the behavior.

2.
It's very simple with this behavior. Just apply a force at an offset. The offset can be any point on the object and applying multiple forces work as expected

For what you're actually trying to achieve the best current solution is to join all the objects together with physics joints, but even then it can't be completely rigid. A proper solution where all the joined objects form one rigid object is possible with the box2d or chipmunk libraries themselves, but nothing is exposed to C2 for design reasons. The question to do it has come up before and my proposed solution then was to use the chipmunk library with js instead of the behavior.
B
94
S
33
G
118
Posts: 5,393
Reputation: 75,847

Post » Tue Feb 23, 2016 9:21 pm

Well I think I chose the wrong tool for this particular idea. C2 seemed to have everything I need in simple and quick-learned package. Yet physics is not one of them. I've just realized I can create instances on the fly, but there is apparently no way to refer them from the physics engine. Well, my bad. I should have tried free edition first.

I don't want to give up on C2 though. GM would take me a lot more time to get familiar with. That's why I ditched the idea of learning Unity in the first place. I have experience in coding in some languages but nothing suitable for games, plus it would take me ages to make something professional looking and fun to play. I like how you can make a lot with just several events, that would normally require tons of lines. As a game designer, graphic designer and programmer in one person, C2 is maybe one and only way to make game(s) in reasonable time and without spending months or years getting familiar with it.

I'll try to re-think the whole concept without physics, but it will most likely destroy the whole gameplay. I've seen some very complex games made with C2, so I guess if I avoid physics for the time being, there shouldn't be "anything" that I couldn't do with C2. My OT stops here.
B
6
Posts: 14
Reputation: 278

Post » Wed Feb 24, 2016 7:21 am

@mh11
I don't follow. How are you not able to to refer to them from physics? Guess I'll have to look at your other topic.
B
94
S
33
G
118
Posts: 5,393
Reputation: 75,847

Post » Wed Feb 24, 2016 4:40 pm

@R0J0hound I haven't mentioned that there. I just found out. Maybe I'm wrong, I'm pretty new to C2. Whenever I want to make a joint or apply force with regular physics I can't see how to address specific instance in the event. It always applies to all of them. I couldn't find anything on that topic via google either.
B
6
Posts: 14
Reputation: 278

Post » Wed Feb 24, 2016 7:08 pm

@mh11
I've seen the question come up often and there are two solutions.
One is to pick one object and store it's values in a variables and then in a separate event pick the other one and use the values to do something. One quick thing you can save to a variable is the object's iid then you can use expressions like Sprite(1).x+sprite(2).x to add the x values of two separate instances for example.

Another more useful thing you can do is to make a family containing only that one object type, then in events you can pick two separate instances independently. If you use C2's physics you have to use the family route.
viewtopic.php?f=148&t=91829&p=718895&hilit=rope#p718895

With the chipmunk behavior it makes things simpler, you specify the uid of the other object to attach the joint to and avoids having to use a family or even picking at all if you want to design joints in the editor.
https://dl.dropboxusercontent.com/u/542 ... test2.capx
B
94
S
33
G
118
Posts: 5,393
Reputation: 75,847

Post » Thu Feb 25, 2016 7:44 pm

I've heard this has better results than box2d... might someone be able to tell me how to apply force at angle?

I can see there's apply at offset, etc... but I'm trying to covert my current code over. Isn't it as simple as apply force at 90 degrees? I keep reading that this is used for joints etc... so am I using it for the wrong thing?
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
84
S
15
G
7
Posts: 990
Reputation: 11,229

Post » Thu Feb 25, 2016 8:01 pm

@AnD4D

I'm using chipmunk for racing game, and I have made the turning by applying force at offset:
CasuRally

Up arrow controls the force
Left and Right controls the offset
B
70
S
24
G
9
Posts: 175
Reputation: 7,539

Post » Thu Feb 25, 2016 8:36 pm

@neverk

Surely that means you have to have a bunch of variables controlling such things. The simplicity of the normal physics engine is you just set the physics force strength and the angle.

My code currently simulates something of a black hole. The closer you are to it, the greater the force. Can't see how I'd achieve the same with this one.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
84
S
15
G
7
Posts: 990
Reputation: 11,229

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 1 guest