animating character controller translation; Ani.Mate in C#

what i want to do is trigger a canned “dodge” move in the player character when a key is pressed. when this dodge move is triggered, the player character capsule should smoothly move a few units on its local x axis over a specified period of time, respecting collisions (so that they don’t go dodging through any walls) and unable to resume normal movement until the move is finished. i tried using Ani.Mate:

	void LungeRight () {
		print ("lunging!");
		lungingRight = true;
		Hashtable props = new Hashtable();
		props.Add("position", new Vector3(-2f,0,0));
		Ani.Mate.By(transform, 0.25f, props);
			lungingRight = false;
			return;
	}

but this works with the global axes which is obviously useless for my purposes.
is there a way to translate along local axes using Ani.Mate? maybe i’m not looking hard enough, but i’m not finding any example of that on the wiki page. and the wiki article doesn’t indicate the right syntax for using “callback” in c#, which i’m assuming is what would get the movement to be constrained by collisions.

or could i animate the move in a 3d modeling program and have the character controller respect collisions when executing it?

don’t use new Vector3(…)

But instead use

tramsform.forward / transform.up / transform.right or better a sum of them according your desired movement.

In this case obviously only transform.right

thanks for the quick reply, that took care of that part. it’s still going through walls, though. will “callback” fix that, and do you know the c# syntax to use it?

if you are using a character controller it shouldnt go thru walls by default.

Check the walls have “generate collider” turned on in the mesh and that you are using the move call on the character controller to move, not manually overriding the position transform.

Also make sure your character controller’s collider is the corect scale…if it is too small then some of your player geo will go thru the wall.

i’m testing this in the warehouse/office scene included in the iphone occlusion culling demo, so the environment mesh is actually a collection of box colliders which work fine in every other case. and my character collider is more than large enough. i suppose this is happening because i’m moving the character transform itself and not the character controller, which the “callback” option might fix… does anyone know how to use it in c# with a character controller?

changed the thread title to be more accurate; maybe someone who knows more about ani.mate will notice now.

I’m not sure how the character controller handles collisions but using Ani.Mate you directly update the position of the character which doesn’t give it a chance to react to collisions.

There’s no easy solution for that and Ani.Mate isn’t really made to work with objects that react to collisions. It works great for elevators which only affect physics but not for objects that are affected by it.

What you could try is to detect the collisions in the character controller and then stop the animation when a collision occurs.