Items moving on conveyor belt

0 favourites
  • 6 posts
From the Asset Store
This is a code so you can see the same skin on all screens (peers). Each peer gets a skin, in addition to 4 directions t
  • I am trying to make items move along a conveyor belt and stop and queue up behind each other when they have no where to go,

    It mostly works with

    item is over lapping belt right
    item is overlapping item(Inverted)
    
    set x to self.x+1[/code:27ssxl4x]
    
    This works fine until they need to move again and as they are overlapping the will not move.
    
    i have tried using distance(item.x,item.y,item.x,item.y) < 10 then move but i think i need some sort of picking instance here as it compares itself to itself i assume.
    
    any offer on an efficient way to do this, i have browsed the forums and tried other ways such as line of sight but still no luck
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • any offer on an efficient way to do this, i have browsed the forums and tried other ways such as line of sight but still no luck

    There is a Pick nearest/furthest condition you could use to select the item closest to the end of the conveyor belt.

    So, assuming the belt object has origin in the middle, you could do something like this:

    [event]item is over lapping belt_right
    [sub-event]item is overlapping item(Inverted)
    or
    pick nearest item to (belt_right.X + (belt_right.Width/2), belt_right.Y)
    
    [action]set x to self.x+1[/code:1chj1ybf]
  • Hey man thanks for the reply,

    This did not work either seems to just move the one closest to the edge and the others stay still until the first one has reached the end.

    I tried what you said multiple ways and with/without 'or'

    I also tried [pick nearest to (self.x+self.width/2) which also didn't work Heres a capx if its any help dropbox.com/s/nojwo9y9fx2jrd4/conveyor2.capx?dl=0

  • That capx is a bit different to the code you posted, being physics based and seems to work fine.

    Anyway, this change using is overlapping at offset should allow the other boxes to move once the one to the right of them has moved away a small distance:

    item is over lapping belt right
    item is overlapping item at offset (2,0) [Inverted]
    
    set x to self.x+1[/code:39ndv7uq]
  • Overlap at offset would work best for that.

    Overlap is good for reading a position but not for stopping the overlap.

  • That worked a treat, had tried overlap at offset the other night but didn't work, was very late when i tried so who knows what numbers i put with it haha

    Thanks for your time, much appreciated.

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