Physics. Constraining to one axis?

Discussion and feedback on Construct 2

Post » Mon Nov 12, 2012 11:20 pm

Hmmm ... Really enigmatic ... Wait ...you could make a script that makes the object move behind or in-front depending on if the player is colliding with the fences ... You wouldn't need to make the fences physical ...
B
34
S
16
G
16
Posts: 2,222
Reputation: 16,564

Post » Mon Nov 12, 2012 11:29 pm

I don't quite understand what you mean
B
11
S
4
G
3
Posts: 70
Reputation: 3,071

Post » Tue Nov 13, 2012 12:06 am

Can't you just set it as immovable, then programmatically update its position. That's what I do for floating platforms that move side to side.
Moderator
B
72
S
13
G
11
Posts: 900
Reputation: 11,783

Post » Tue Nov 13, 2012 11:26 am

@Thehen that means he doesn't get physics interactions.

This is an interesting challenge!
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Tue Nov 13, 2012 11:57 am

I must be the only one who thinks this doesn't make sense :/ Surely the point of implementing a physics behavior is so that objects react as realistically as possible (?!)

Having an option to constrain an aspect of the physics implementation would surely invalidate that.

My 2 cents.

zen
If your vision so exceeds your ability, then look to something closer.
Moderator
B
120
S
28
G
68
Posts: 4,840
Reputation: 48,281

Post » Tue Nov 13, 2012 3:50 pm

Well, I gave some examples earlier. It's a pretty standard part of any physics system.

And in fact Box2D supports this type of constraint - it's called a Prismatic Joint. And it's section 8.7 of the manual

http://www.box2d.org/manual.html

@Ashley. Any chance we could get these added to the physics? And the other joints? Moar physics!
B
11
S
4
G
3
Posts: 70
Reputation: 3,071

Post » Tue Nov 13, 2012 8:40 pm

From a brute force perspective you could use other physics objects to constrain the single axis object.

For you scales example you could have the scale (...) holdy-thing (Brain block!) sandwiched between two immovable and invisible physics objects, similar to a chute or vertical tunnel, and using events disable collisions between these constraints and every other object except the scale.

Could the clamp feature be of any use here? I'm a bit miffed on how the feature works but I've used it to constrain an object to an axis before.
B
49
S
14
G
3
Posts: 540
Reputation: 5,611

Post » Thu Nov 15, 2012 9:08 pm

OK. I have kind of done it. Not quite as clamped as I would like but still not bad.

https://dl.dropbox.com/u/104684620/force%20test.capx

Pick up the pink blocks and use them to play around with the blue platform. There is some physics wonkiness - but part of it is to do with combining physics with drag 'n' drop which is never a good idea.

Basically this is achieved in a single line of code! Every tick, a force is applied proportional to the distance away from the target Y. This creates a spring effect and if you make the force large then the spring is pretty strong. Note that the spring is easily able to cope with gravity.

Better results could be achieved by balancing density, force strength, linear damping.

So the first rule of game physics applies: do everything with forces.
B
11
S
4
G
3
Posts: 70
Reputation: 3,071

Post » Thu Nov 15, 2012 9:10 pm

In fact, setting linear damping to 1 gives much more stability.
B
11
S
4
G
3
Posts: 70
Reputation: 3,071

Post » Fri Nov 16, 2012 1:56 am

https://dl.dropbox.com/u/7765312/weeee.capx
:D
B
45
S
19
G
10
Posts: 562
Reputation: 9,543

PreviousNext

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 2 guests