[BEHAVIOR] Chipmunk Physics

Post your completed addons to share with the community

Post » Mon Dec 21, 2015 6:44 am

here's an exmaple: http://1drv.ms/1YvddfG
Seems like setting the angle before joining will mess it up. Any way to get around this?
B
48
S
23
G
66
Posts: 1,144
Reputation: 39,059

Post » Mon Dec 21, 2015 8:50 pm

@Prominent
I do not understand what is happening here.

If in the editor
sprite2.angle = 95
sprite3.angle = 240

And you make an event like:
Start of layout
--- create gear joint with phase = sprite3.angle-sprite2.angle

Then sometimes the objects will rotate 360 before settling.

However if you set the angles with events then it's perfect.
Start of layout
--- sprite2: set angle to 95
--- sprite3: set angle to 240
--- create gear joint with phase = sprite3.angle-sprite2.angle

or you even can do this:
--- sprite2: set angle to self.angle
--- sprite3: set angle to self.angle
--- create gear joint with phase = sprite3.angle-sprite2.angle

EDIT:
Ah, I see what the issue is. Internally in C2 angles can be any value. When you access them however, they are always returned in the range [0,360). So it would be a fix from my end. Till I do that the above solution will work.
B
94
S
33
G
118
Posts: 5,395
Reputation: 75,851

Post » Mon Dec 21, 2015 9:05 pm

@R0J0hound , Hm.. seems like that won't fix it in a specific project I have where I'm creating multiple joints on multiple objects (some of which may have more than one gear or pivot).. I try to set all their angles to self.angle, which helps sometimes, but other times they spin like crazy.
At the moment, I'm just resorting to using two pivot joints to join objects without the gear joints, since the gear joints appear to be unusable in my case. If you get around to fixing that, I can try reverting to the gear joints to see if the problem still persists,
B
48
S
23
G
66
Posts: 1,144
Reputation: 39,059

Post » Thu Dec 24, 2015 2:56 am

hi rojo, i'm getting this error, it's erratic so sometimes I get it, refresh (changing nothing at all) and then it works fine. (happens about once every 10 times)

Javascript error!Uncaught TypeError: Cannot read property 'x' of nullhttp://localhost:50000/rojoChipmunkBeta_behavior.js, line 5173 (col 25)This may be a bug in Construct 2 or a third party plugin or behavior - please report it to the developer following the bug report guidelines. Subsequent errors will be logged to the console.
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Thu Dec 24, 2015 8:42 pm

@keepee
Do you have a capx that reproduces it? That line is run when applying forces, but it works here.
B
94
S
33
G
118
Posts: 5,395
Reputation: 75,851

Post » Tue Dec 29, 2015 2:40 pm

Hello,

I'm new at construct 2.
I have installed chipmunk and I intend to use it for a small racing game.

First, I notice that when used with the car behaviour, it's not working well.
So, I assume that I have to rewrite the car behaviour if I want to use chipmunk (same for physics behaviour).

Also, I am wondering if chipmunk is OK with 3d isometric graphics.
And if yes, how to do the transposition?
I mean, is there a way to manually handle the collisions?
Because in 3d iso, objects might be displayed "behind" and not colliding.

Ouais
B
6
S
1
Posts: 44
Reputation: 773

Post » Tue Dec 29, 2015 6:43 pm

Hey @ouais25 hi.

Welcome to construct 2 community.

The best way to use the chipmunk and generally behaviors that involves physics is to use it alone ,dont mess physics behaviors with other behaviors (car behavior) because they will act strange (by the way you can easily create a car movement through chipmunk).

About the physics collision now and the 3d iso thing , well i think IMO chipmunk can handle physics collisions, joints and other stuff better than the build-in physics behavior (and of course has ,collision group-layer and the amazing Collision info). A tip about the iso collision is to make invisible objects with the chipmunk behavior to handle the collisions.
B
36
S
16
G
1
Posts: 59
Reputation: 3,501

Post » Tue Jan 05, 2016 4:40 pm

Thanks saour,

My assumption was correct and I will go with chipmunk and recreate a car behaviour.
It's a bit a pity that the behaviours are not compatible with each others (I struggled lately with the direction behaviours as they don't behave the same actually, i.e. with the management of the angle).

For the iso 3D, your tip is indeed interesting. Probably the way to go.
I am making a first little game in iso 3D for my kid and the design in ISO 3D is very time-consuming and constraining (i.e. if going for multiple part sprites with damage management), I'll probably go 2D from above for the more complex game I intend to do afterwards.

Ouais
B
6
S
1
Posts: 44
Reputation: 773

Post » Tue Feb 02, 2016 2:12 am

I'm trying to build a simple ragdoll with this, but I am unsure how to use the joints? Like, what goes in the UID section, are the first set of parameters discussing the x and Y of a select point to offset the first object to? or FROM?

and the second set are they discussing the UID object you put in the parameter? if created a ragdoll or an object with parts (like a pulley) should I only connect objects FROM something or can I get the parts to connect to a master object by a reference and which field uses what?

I am sorry for the questions, I'm jsut a bit confused and not gettingthe results id like. Maybe I'm just too stupid. (happens)
B
5
S
1
Posts: 68
Reputation: 515

Post » Tue Feb 02, 2016 3:22 am

@Itenimum1
The uid tells what other object to connect to. I could have used an object type instead, but using a uid instead makes stuff like connecting to other instances simpler. As an example if you want to add a joint to Sprite1 to connect to Sprite2 you would use Sprite2.uid.

For the xy's they define where on the objects the joint is connected.
"rect" and "polar" are offsets from the object, but it's also relative to the object's angle. So for example if you used "rect" with x=32, y=0 and the object had a angle of 90 then the object would be connected 32 pixels below the object's center.
"imagepoint" should be self explanatory.
"layout" is a layout position, which in turn is used to calculate an offset. It's probably simpler to wrap one's head around than "rect" and "polar", since it's not relative to angle.

Depending on the joint there usually are two anchor points, one for each object. The only exception would be "add anchor joint at XY", but since ever field has a description so it should be understandable.
B
94
S
33
G
118
Posts: 5,395
Reputation: 75,851

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 0 guests