Physics. Constraining to one axis?

Discussion and feedback on Construct 2

Post » Sun Nov 11, 2012 8:09 pm

Is there a way to do this? Say that I want an object to have physics in along the x-axis, but always have the same y-axis position - as if it were running on a rail.

I can't find a way - and hacking it through setting Y every frame has nasty results.
B
11
S
4
G
3
Posts: 70
Reputation: 3,071

Post » Sun Nov 11, 2012 8:34 pm

A curious conundrum! I wonder how this could be done...
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Mon Nov 12, 2012 12:24 pm

I wonder if it is possible to expose an expression like gravity direction from the official plugin?
B
7
Posts: 38
Reputation: 683

Post » Mon Nov 12, 2012 2:47 pm

Could we have an example of when this effect would be used?
B
49
S
14
G
3
Posts: 540
Reputation: 5,611

Post » Mon Nov 12, 2012 8:50 pm

Sure. There are lots of possible examples.

Scales - where the more weight you put on an object caused it to move down.

Pistons - moving up and down under physics - but never moving to the left or right.

B
11
S
4
G
3
Posts: 70
Reputation: 3,071

Post » Mon Nov 12, 2012 8:52 pm

The gravity direction doesn't help much. You can fake that by switching off gravity and applying the force yourself. But still other objects can knock it off the axis you want to constrain it to.
B
11
S
4
G
3
Posts: 70
Reputation: 3,071

Post » Mon Nov 12, 2012 9:21 pm

What happens when you try and use something like "every tick set x position to 100" on a physics object?

would that restrict it vertically?
B
50
S
21
G
8
Posts: 844
Reputation: 10,299

Post » Mon Nov 12, 2012 10:03 pm

You could ... create two non-movable sprites just behind and in front of your object in an axis ?!

Try that ...
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Mon Nov 12, 2012 10:35 pm

@justifun This I have tried. And the results are erratic. Seems to work well if the object is not colliding with anything. But if it's touching anything then it slows it down as if it had a massive coefficient of friction. Tried various workarounds - upshot is - it didn't work.
B
11
S
4
G
3
Posts: 70
Reputation: 3,071

Post » Mon Nov 12, 2012 10:36 pm

@whiteclaws. Sort of tried this. Problem is that all other physics objects can also collide with those objects - hence they become not useful.
B
11
S
4
G
3
Posts: 70
Reputation: 3,071

Next

Return to Construct 2 General

Who is online

Users browsing this forum: neverk, Psychokiller1888 and 15 guests