Smooth force

I want to add a force to an object and have it look like I’m translating the object in an even manner.

I’m trying to simulate a conveyer belt. Since I’m using Blender, I can’t create an animated conveyer belt, so I’m trying to fake it. I’ve got a stretched out cube, with a scrolling texture on it. When an object falls onto the conveyer belt, I want to add forces to the object.

Sounds simple, but I’m running into trouble with making the object look like it is moving with the conveyer belt. I can’t use a constant force, because the object moves faster, and the different ForceModes for AddForce() are not doing the trick.

I’ve tried pushing the object along with an invisible box collider, but that doesn’t work either. The only thing I haven’t tried yet is attaching a parent to the object when it hits the conveyer belt and translating the parent.

Any ideas, thoughts, help? Thanks!

If force isn’t a problem while the object is on the conveyor belt you could just translate the object around at the speed of the conveyor belt.

I have a similar problem in the game I’m making where certain objects just don’t have the right feel when moving under proper physics so I have to take control of their movement at times instead of letting the physics engine work it’s magic.

I actually have to simulate certain collisions because I just can’t tune the physics engine to produce the exact desired effects.

You could try setting the velocity directly.
The animated invisible box should really work. (Make sure that the box has a kinematic rigidbody though)

Yes, I would use rigidbody.velocity = … That has worked well for me when I need to deviate from natural physics.

I would do some code like this:

Script for your box:

var conveyor : GameObject;

private var touchingConveyor = false;

function Update ()
{
	if(touchingConveyor)
	{
		conveyorScript = conveyor.GetComponent(Conveyor);
		if(conveyorScript) transform.translate conveyorScript.direction *  conveyorScript.speed * Time.deltaTime;
	}
}

Script for your Conveyor:

var direction = Vector3.zero;
var speed = 0.00;

function OnTriggerEnter (collider : Collider)
{
	script = collider.GetComponent(Movable);
	if(script)
	{
		script.touchingConveyor = true;
		script.conveyor = gameObject;
	}
}

function OnTriggerExit (collider : Collider)
{
	script = collider.GetComponent(Movable);
	if(script) script.touchingConveyor = false;
}

Thanks for the help, everyone! The ideas were great, and I am definitely altering the velocity directly. What seems to be working best, though, is after a collision occurs, I am casting a ray downward to see if my piece is still above the conveyer belt. If it is, I’m adding velocity.

I’ll publish a webplayer when I’m at a decent phase of the prototype.