How do I Create Physics Structures

Get help using Construct 2

» Tue Nov 10, 2015 6:02 pm

I want to create structures such as this:

To be created randomly out of physics objects.

I'm having a spot of bother with physics joints. Lets say the lighter square is the centre object, this has 4 image points on each side, I want to attach a random number of collars to random sides of the centre object, and then stick them together with a joint. I then want more large squares to spawn off the collars and so on and on until I have this one joined structure.

My problems in testing are that even though I am ignoring collisions between the objects, when I spawn a collar off an image point of a square then set its angle relative to that of the face of the square it's spawned at, when I apply a limited revolving joint, the item spins to an angle then sets facing an awkward direction.

I don't quite know the best theory for achieving something like this. My reason for wanting to use physics is so that I can influence the whole generated structure as one by external forces.
B
44
S
13
G
8
Posts: 622
Reputation: 7,417

» Tue Nov 10, 2015 8:04 pm

I remember having trouble with limited revolute joints a while back when doing a ragdoll. I think what I was doing wrong then was using absolute angles for the rotation limits when they should be relative to the object's default zero degree position (i think). Anyway here's what it looked like:

https://dl.dropboxusercontent.com/u/523 ... Joints.png

I hope this is going to be a space station for your mining game
B
27
S
12
G
1
Posts: 157
Reputation: 3,359

» Tue Nov 10, 2015 8:52 pm

I think the angles of freedom of a limited revolute joint are relative to the angle from ObjA to ObjB, at time the joint was created.
Learning other engines, but C2 still rocks.
B
81
S
22
G
96
Posts: 2,468
Reputation: 58,353

» Tue Nov 10, 2015 10:16 pm

@mattb / @colludium- thanks I'm still trying to work this out, i'll share a capx later if anyone is interested.

@mattb - might have something to do with mining :b
B
44
S
13
G
8
Posts: 622
Reputation: 7,417

» Tue Nov 10, 2015 10:44 pm

I think what's unintuitive, or little known, is that you can add positive and negative numbers into the parameters windows when setting up the joint. Have a look at this simple example to see what I mean.
Learning other engines, but C2 still rocks.
B
81
S
22
G
96
Posts: 2,468
Reputation: 58,353

» Wed Nov 11, 2015 10:04 am

@Colludium / @mattb

I see what you mean there Colludium. I struggled with this for a while but it's pretty complex and messy. Problem is first generating the physics objects, setting the angle, then applying the joint relative to that angle - which seems to for some reason cause all the objects to spin on the spot which then messes up the angle at which other parts of the structure are spawned...

So I've brute forced it using the pin to object which is a real shame as the forces are not relative to the core object it's entirely arbitrary. Also the structures aren't being generated, they're hand-made but you can get an idea for what I'm trying to do with this demo:

https://dl.dropboxusercontent.com/u/3317708/Space%20Lander%200.1/index.html

Use WASDQE to thrust in various directions, hold shift to stabilise. R restarts layout.

Match angle, watch the speed
B
44
S
13
G
8
Posts: 622
Reputation: 7,417

» Wed Nov 11, 2015 10:29 am

If you move physics objects (using non-physics events) after they have been declared to the physics engine then they are given huge velocities because of the distance they move in one tick. If you move them you need to subsequently assign them zero velocity to negate this effect.
Learning other engines, but C2 still rocks.
B
81
S
22
G
96
Posts: 2,468
Reputation: 58,353

» Wed Nov 11, 2015 1:54 pm

@Colludium - ah I didn't know that, interesting. Will let you know how I get on.
B
44
S
13
G
8
Posts: 622
Reputation: 7,417

» Wed Nov 11, 2015 1:55 pm

@Colludium - so I'd 'set angle' and then 'set angular velocity' to 0 sort of thing?
B
44
S
13
G
8
Posts: 622
Reputation: 7,417

» Wed Nov 11, 2015 2:34 pm

If you've moved either object then it's worth setting velocity first, then create the joint. The order of events might not matter, but I think that's the most logical.
Learning other engines, but C2 still rocks.
B
81
S
22
G
96
Posts: 2,468
Reputation: 58,353

Next