Constant Force

Get help using Construct 2

Post » Thu Jan 19, 2012 11:51 pm

hey everyone,
im trying to create a conveyor belt so a box will drop on and move along it. Ive tried appying a force to the box on collision with the belt but theres a problem, the force seems to only apply one making the box drop on, move a little then stop. is there a way to apply a constant force with contact on the belt?
also the belt will often be different angles so the box will need to adapt.
B
10
S
1
Posts: 39
Reputation: 1,053

Post » Fri Jan 20, 2012 12:38 am

Last edited by Yann on Sun Sep 14, 2014 9:53 pm, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Jan 20, 2012 10:34 am

woah, didnt expect to see something that works so good, this looks great im still trying to get my head around exactly what you did, but i think im getting it. i still dont quite get where the movement is determined from even though it clearly works
thanks Yann!
B
10
S
1
Posts: 39
Reputation: 1,053

Post » Fri Jan 20, 2012 10:49 am

The thing that is hard for this kind of behavior is to detect the conveyor belt. 'Cause when the cube is on it, it doesn't overlap it so you can't really know the nature of the 'ground' your on.
So I used another Sprite for detection. I pined it to the box and made it slightly bigger so it sticks out of the cube (you can see that if you set the boxColl object to visible in properties)
When the box detects the conveyor belt, it takes its velocity instance variable and put it in the move instance variable of the box.
And as soon as the move instance variable isn't equal to 0, bam it moves.

Oh... Well I don't need the 'move' variable I can directly plug the velocity to the box, you can re download the .capx to see the difference if you want.

The neat things is that you can have conveyor belts with different speedsYann2012-01-20 10:49:57
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Jan 20, 2012 11:21 am

yes! thyanks to you ive got some sweet looking conveyor belts. the thing i love about your method is the collision with the cube looks smooth in runtime, ive just been testing tons af angles for the belt and every time the box just sticks to the belt and moves. i love it
there is one issue however, the direction of the belts on my game only go to the right of the screen, even if i place the belt the other way around, all boxes still move to the right :S
B
10
S
1
Posts: 39
Reputation: 1,053

Post » Fri Jan 20, 2012 11:23 am

@LukeMarkBrady

Have you given the conveyor a negative velocity?

Yann's example has a positive value for moving left and a negative value to move right.zenox982012-01-20 11:24:51
If your vision so exceeds your ability, then look to something closer.
Moderator
B
120
S
28
G
68
Posts: 4,849
Reputation: 48,299

Post » Fri Jan 20, 2012 11:42 am

ahh yes i see. is there a way to set this during runtime, in the game the player can click two points and a conveyor will appear inbetween. now a positive value will work for conveyors made fromk left to right, but i want negative when players make conveyors from right to left.
B
10
S
1
Posts: 39
Reputation: 1,053

Post » Fri Jan 20, 2012 12:06 pm

Easily. It's just an instance variable so you can set it's value to whatever you wish. Just use a condition to check for the player activating a switch (or whatever) and set the conveyor instance variable accordingly.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
120
S
28
G
68
Posts: 4,849
Reputation: 48,299

Post » Fri Jan 20, 2012 12:18 pm

is there even a condition that can tell if the object is made left or right or right to left?
B
10
S
1
Posts: 39
Reputation: 1,053

Post » Fri Jan 20, 2012 12:28 pm

never mind, i found it
i just made an event that checks if the x value is higher than point b, if not, chnage the velocity to -100
works like a charm.
B
10
S
1
Posts: 39
Reputation: 1,053

Next

Return to How do I....?

Who is online

Users browsing this forum: Justin1967, qaisarehman, Yahoo [Bot] and 33 guests