conveyer belt

i try to simulate a conveyor belt, it doesnt need to be exactly working with rotating parts etc.
I just want to have a flat surface as a belt. (but maybe many small belts so i could layout turns)
On the conveyer belt i like regularly spawn objects

And then objects should take a certain speed on (colision?) with this first belt.
But if a second conveyor belt after it is turned of, then they cannt move there
and so then they start to qeueu on the first belt.

The things i wonder are :

  • how can have a non actor object (the conveyor) and the cubes (actors) have detect on which conveyor they are.
  • how can the cube take a direction on colision detection as provided by the belt
  • how to lock in place the cubes that are put on hold by the band (they shouldnt be pushed then by the newer cubes)
    and i dont like strange collision effects to happen then (forces building up or so).

I’m probably not qualified to answer this, but couldn’t you set up a few variables (properties) for recording/detecting what conveyor an object is on? You could do the same thing for the collision direction, based on whatever influences are involved. And to lock the cubes, you could probably use a keyframe to turn on/off the animation to control their physics.

  • [- deleted - ] -

well thats just what i cant seam to do right here, i made something like that but it doesnt behave as i would like, it doenst queu nicely
test.blend (477 KB)

use the localized position to the conveyor belt ‘tile’ (collider objects) to pull the object to the center, and also move the object at an exact rate, have a hirachy (like tile 0, tile 1 etc, so when a object is touching two colliders you can choose the one with the higher value, etc,

Hello.
Here’s my example.
mzConveyor.blend (131 KB)

@@mziskandar Thats a nice example, not sure how you made it go around, in my case i’d like the bands to folow a path (think of the game factorio or how airports move bags around in all kind of direction)… ehmm
factorio is probaply a better example
I think you used a curve and then somehow animated it, but i preffer not to use animated since i want people to control the belts by keys (forward backward hold-still)

@@BluePrintRandom not sure what you mean, i dont get it…

@BluePrintRandom helped me a lot.
And i got a new test file to work on it.
I think this approach works better
a few things left i want to have it move on turn on turn of base.
Curently spacebar has to be presssed to keep it all going, i’d like a single spacebar click to start or stop the movement over a longer time period (as i think it might go smoother then).

Convey2.blend (542 KB)

the script


import bge


def main():

    cont = bge.logic.getCurrentController()
    own = cont.owner

    Collision = cont.sensors['Collision']
    Keypress = cont.sensors['Keyboard'] 
    
    
    if Collision.positive and Keypress.positive:
        for objects in Collision.hitObjectList:
            Local = objects.worldPosition-own.worldPosition
            Local = own.worldOrientation.inverted()*Local
            
            if abs(Local.x)>.05:
                if Local.x>.05:
                    objects.applyMovement(own.worldOrientation.col[0]*-.11,0)

                     # added to solve race condition of fighting for mid
                    objects.applyMovement(own.worldOrientation.col[1]*.25,0)    
                else:
                    objects.applyMovement(own.worldOrientation.col[0]*.11,0)

                     # added to solve race condition of fighting for mid
                    objects.applyMovement(own.worldOrientation.col[1]*.25,0)    
                        
                objects.worldLinearVelocity*=.15
            
            else:    
                objects.applyMovement(own.worldOrientation.col[1]*.25,0)    

main()


I can make a float, that holding space adds to, to a max number,

releasing drops back to zero over time,

this property can be used in the movement to control how fast the object is ‘fakeccelerated’

Is it possible to do that by setting a global var ? above main()
I dont know how BGE handles scripts

just use a property :smiley:

own[‘Amount’]

one sec- example incoming !

edit:
File and video

Attachments

ConveyAndControl.blend (479 KB)

Awesome, you made a youtube about it.

I think i gonna read some more about those property nodes you use, i dont get it what they exactly do how you communicate between them, in relation to the script code

Spacebar sensor-----------------------------and-----add 1 to Strength
property is less then or equal to 99/

this will make a property climb to 100 if you hold space

Not pressing space------------------------------and—add -1 to strength
property is greater then or equal to 1—/

this lowers the value back to zero when you release spacebar

(not pressing space, is a keyboard sensor, set to space with inverted checked)*

property sensors link to game object properties inside the same object as the sensor, and are quite handy as events to trigger python, or for manipulating a property value with a cap etc,

logic bricks (property actuator) can manipulate propeties in a game object without using python and python can access the properties*

own[‘NameOfProperty’] is how you access a game object property in python

so you can access propeties inside a python in other game objects using
own.scene.objects[‘GameObjectName’]
but this sorts through all objects in the scene, so it’s best to store a reference to another object as a property inside a object.

if 'TargetGameObject' not in own:
    own['TargeGameObject'] = own.scene.objects['NameOfTarget']

later you can use

own['TargetGameObject']['NameOfProperty'] 

to access properties in a outside object without digging up the game object each frame

(bump significant edit)

Curently spacebar has to be presssed to keep it all going, i’d like a single spacebar click to start or stop the movement over a longer time period (as i think it might go smoother then).

You can set up an Always sensor to watch for the spacebar and then toggle it true or false with a XOR to activate or deactivate the action. It would be much simpler than using all that code and relying on a counter that has a limitation.

The counter, is how fast the belt moves, so it does not start up, and stop instantly. it’s not a limitation, it is a feature.

I gave him a example where I used a bool to replace the spacebar sensor in a PM.

I thought he wanted the conveyor to stop when too many cubes get piled up.

Having had a lot of experience with computer programming in the past, I can say that to solve a logic problem if it’s important to first clearly understood what parameters are involved in the task at hand.

  • Conveyor identity
  • Cube identity
  • Conveyor speed (on/off)
  • Cube position on conveyor
  • Identity of next conveyor in queu
  • Direction of next conveyor

These are the parameters that I can identify from the problem as it was stated.

At the very least, each conveyor and each cube needs to be identified by the other when they’re together, so a value should be stored in each cube that tells it what conveyor it’s on. Another value should hold it’s position on the conveyor in relation to other cubes on the same conveyor. This value goes up or down by 1 whenever a cube leaves or enters the conveyor, and the values for all the other cubes are shifted. When the maximum number of cubes is reached, the conveyor stops (or slows down). Each conveyor (or cube) should also hold a value for which direction the cubes should take when they switch to it.

That’s all I can add, given the way the problem was stated. Once @Razorblade identifies the parameters he needs to take into consideration, it will all become so much clearer how to go about it.

The only thing I’m not sure about is how he plans to move the cubes from one conveyor to the next. Not that it would be a problem.

0 _ 0

my conveyor belt, works like a conveyor belt, that conveys… using a belt.

I apply movments to center the object, and to push the object along.