Conveyor Belt advice

Hi there, I’m working on conveyor belts at the moment, and they’re proving to be somewhat of a task.

I initial had the idea for each belt to have 4 different locations at which it could be and just program it to make it look like an item was moving on top, I.E: Have a gameobject move slowly to the next location and then snap immediately back to it’s original location while changing it’s image to the next item on the belt.

However, this has caused some problems, such as corners, such as moving the item in the correct direction. Etc…

I was wondering if you had any suggestions for how I could make this work, the belts are individual gameobjects that are placed in a grid like system, they are 2 “squares” long and 1 “square” wide.

Besides my way, that isn’t working and really sacrifices FPS, could you think of another way to do this? I do not mind if the player moves when on them, that’s not really a necessity.

Thought it might be worth mentioning that the game is 2D.

I’m free to share anything I have so far.

Thanks a lot.

This is good information in terms of the optimisation that I should be doing and some of the underlying functionality I need to provide, but I’m still a bit unsure about how to implement this. I’ve been giving it a think and maybe a Dictionary with connected Conveyor Belts could work, but even then, how do I display the items on the belts.

I think you want to divorce the presentation of the belt graphics from the effect of moving along the belt.

I.e., have a separate test for an item that says “I am on this belt going this way right now,” and accordingly affect its motion: if it’s static, just move it, if it is a player/enemy, then bias its motion towards the belt.

Then you can just graphically engineer whatever kind of belt you want to do: texture scrolling, a series of sprites, a particle flow field, slide-and-snap-return like you said, etc.

In all cases, visual presentation remains completely detached from function, and only concidentally “kept in sync” visually. This approach will result in the least headaches going forward as you tune things like speed.