• Register
Post news Report RSS Conveyor belt physics and UV tricks

I had a bit of a problem making a secure and fully functional conveyor belt line that moves any objects on top of it towards one direction at a certain speed, regardless of the object's mass. It should also do so with multiple stacked objects and dynamic moving objects such as the player character.

Posted by on

I had a bit of a problem making a secure and fully functional conveyor belt line that moves any objects on top of it towards one direction at a certain speed, regardless of the object's mass. It should also do so with multiple stacked objects and dynamic moving objects such as the player character.

My personal struggle of scripting a conveyor belt

I tried to put all objects on top of the belt into a list, and move all of the objects in different ways, but the result was always too chaotic. After hours of headache and frustration, I found the solution which was very simple and peculiar.


Basically all you have to do is move the actual rigidbody transform of the conveyor belt backwards, and then forward with MovePosition the same amount, during the same frame. So the belt actually takes one step back and then immediately one forward, but everything that cares about the physical world will only be affected by the latter, so all the objects on the line are pushed forward nice and smooth. No need for lists, triggers or collision detections!

Do this every physics step and you're all set (the conveyor belt rigidbody object):

rigidbody.position -= transform.forward * speed * Time.deltaTime;
rigidbody.MovePosition (rigidbody.position + transform.forward * speed * Time.deltaTime);

Thanks Mr. Hogan, and thank you Google as well! The full post can be found here:

Gamasutra.com

- Timo Kuronen, programmer

The artsy UV tricky side

The conveyor belt is animated using a script which offsets the UV's in sync with rotating gears, which take their speed from the actual belt physics speed controller. So we only need to adjust one value and the animations stay in sync.

Animating the belt with UV offset is the simplest way I could think of and it works pretty much flawlessly. The only downside is the need for a separate texture, but at least it can be kept small and since no geometry is actually moving, lightmapping can be used for the belt.

Looping belt texture


Oh, I also made some other assets which use the uv-offsetting. One can accomplish all sorts of blinking doodads and moving thingamajiggers with this technique. All the screens are animated with uv-offset as well:


As the technique is quite cheap cpu/gpu-wise, we'll be using is for many more things to come.

Thanks for reading!

-Sami Kuronen, 3d artist

Post comment Comments
BrightBit
BrightBit - - 33 comments

Your conveyor belt trick sounds really great. I definitely will remember that!

Reply Good karma Bad karma+1 vote
artindubitably Author
artindubitably - - 10 comments

We're glad you found it useful!

Reply Good karma+1 vote
Koobazaur
Koobazaur - - 20 comments

Just curious, is the game actually in 3D and using cartoony textures or oriented sprites, or is it all Unity 2D?

Reply Good karma Bad karma+1 vote
artindubitably Author
artindubitably - - 10 comments

It's 3D with cartoony textures

Reply Good karma+1 vote
fallingstar01
fallingstar01 - - 15 comments

love it

Reply Good karma Bad karma+1 vote
artindubitably Author
artindubitably - - 10 comments

Thanks!

Reply Good karma+1 vote
asdertxx
asdertxx - - 10 comments

i will follow this game

Reply Good karma Bad karma+1 vote
artindubitably Author
artindubitably - - 10 comments

Thanks! Much appreciated

Reply Good karma+1 vote
manhnd92133
manhnd92133 - - 6 comments

So cool i really love it

Reply Good karma Bad karma+1 vote
artindubitably Author
artindubitably - - 10 comments

Thank you!

Reply Good karma+1 vote
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: