Constant Force

0 favourites
From the Asset Store
Build a thrilling space station scenario with these level assets and characters.
  • 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.

  • woah, didnt expect to see something that works so good, this looks great <img src="smileys/smiley1.gif" border="0" align="middle" /> 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 <img src="smileys/smiley5.gif" border="0" align="middle" />

    thanks Yann!

  • 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 speeds

  • 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 <img src="smileys/smiley36.gif" border="0" align="middle" />

    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

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • is there even a condition that can tell if the object is made left or right or right to left?

  • never mind, i found it <img src="smileys/smiley1.gif" border="0" align="middle" />

    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. <img src="smileys/smiley4.gif" border="0" align="middle" />

  • nope, that didnt work lol. take look and see what i mean.

    mediafire.com

    when i make a line from right to left, as soon as my mouse passes a certain point, the belt switches into -100

    <img src="smileys/smiley5.gif" border="0" align="middle" />

  • you can use a positive number for all your conveyor belt and for the direction you can do something like:

    (cos(conveyor.angle)=0) ? 0 : conveyor.velocity*abs(cos(conveyor.angle))/cos(conveyor.angle)

    in short, if the angle of the conveyor belt is within ]-90;90[ this formula will returns conveyor.velocity if the angle of the conveyor belt is within ]90;270[ this formula will returns -conveyor.velocity if the angle equal 90 or -90 it returns 0

  • worked like a charm =]. thankyou. as you said i used the angle to determine which way it should face and works with no trouble.

    one last thing i had a bit of trouble with,

    when i create one belt object, how do i set it so the 1st bar deletes when i create a second, so only 1 is on screen at a time

  • Global variable current=-1
    +Mouse: on left click release
      +conveyor: pick by UID current
        ->conveyor: destroy
      +conveyor: is Selected
        ->Sytem: set current to conveyor.UID

    Taking into account that you have a 'selected' boolean or something that carry the meaning of "this is the conveyor belt I was just manipulating" that you will switch to false when you drop the belt.

  • ok youve got me, im trying to underetsnad what your saying but just dont get it.. i cant seem to give the 1st conveyor a unuiqe id of say 1,

    then when i make 2... delete 1...make 2 into 1

    i just cant seem to make it functional in the events

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)