iPad: accelerator tilt breaks collider

I’m working on designing an iPad game in which the player tilts the ipad in order to move around the map.

I found this: http://unity3d.com/support/documentation/Manual/Input.html

It does EXACTLY what I needed.

Now, here is the problem.

When ever I this script I get an issue where the collider’s are ignored. Using a very basic example, I made a sphere with a sphere collider and attached a padtilt.js to it. Then I made some walls (with colliders) and a plane (with colliders).

The sphere will stay on the plane, but when I get to a wall it completely ignores and passes through.

I’ve added rigidbody to the walls and that works, but of course the walls bounce all around. I can add the rigidbody to the sphere, but that doesn’t help and make the sphere act all wonky (with or without gravity).

Any thoughts?

I think I figured this out.

Create an empty game object and put your player within that object. Make sure they’re on the same XYZ.

IN the object give it a Character Controller and put the tilt script that I mention attached to that empty object.

On the player object (in my case, a sphere) make sure it has a sphere collider and mesh renderer (default) and add a rigid body with gravity off.

This worked for me. I’m doing a top down pinball like proof of concept, this seems to have worked.

Ok, so … still having issues.

What I’m attempting here is a 2D side scroller. When I tilt an ipad left or right, the character moves. Tap the lower right, the character jumps.

Initially no problem. HOWEVER, the only collider that works is when a flat object us being used for the “floor” or the Y axis … so, if I walk to the X of an object, my character will waltz right through. HOWEVER, the character can jump on top of the object, say a regular cube with a box collider.

The script I’m using for the tilt seems to be the culprit though with my limited coding brain power I can only stick my tongue out at it in frustration.

Here is the code:

var speed = 20.0;
function Update () {
	var dir : Vector3 = Vector3.zero;
    dir.x = -Input.acceleration.y;
	if (dir.sqrMagnitude > 1)
		dir.Normalize();
	dir *= Time.deltaTime;
	transform.Translate (dir * speed);

}

As you see, nothing crazy.

I’m using the prefab Dual TouchPads that come with the ‘Standard Assets (Mobile)’ and I just disable the left movement controller to use ONLY the pad tilting.

I’d really appreciate any help, thoughts or insults on this … I’m feeling mildly retarded here.

OK, I’ve not figured this out. I can’t get any meshes that are imported to accept a collider IF I’m using this accelerator input script provided by Unity. And only the top of a box mesh will register a collider on a pre-generated cube within Unity itself.

Not sure what to do at this point in regards to this. The higher-ups in my company want to see this work, so do I. But sadly nothing yet.

If anyone has any ideas, let me know. Otherwise … back to the drawing board!