Using CharacterController.Move to move character to specific point

I’m trying to create a 2.5D ‘on rails’ game and am using iTween to create a spline that the character’s movement is restricted to. Using iTween, I can calculate various positions on the path and then move the character to the position using transform.position. Unfortunately, moving the character using transform.position seems to make it ignore colliders, even with RigidBody and/or CharacterController set.

I think if I add a CharacterController to the character, and then use CharacterController.Move() to move the character along the path, it will respect the colliders set and disallow passing through objects. I can calculate the direction the character should face based on the next point on the spline, but now I need to move it a set distance to the next point using the Move() function.

Is there a simple way to move a character from Vector3(0, 0, 0) to Vector3(1, 0, 0) or any other calculated position using the Move() function? Thanks in advance for any help!

You can calculate difference between current position and destination point, transform this difference vector from world to characters perspective, and then call move and pass your difference vector as parameter:

Vector3 diff = transform.TransformDirection(movementDestinationPoint - transform.position);

controller is your instance of CharacterController, movementDestinationPoint is vector pointing to the place, where you want your character appear, in world space (thats very important, i suppose u know what does it mean, if not, ask in comment, or better - google out)

No, because that’s explicitly not what Move does. Move() is relative, not absolute. You’d have to wrap it in something else if you wanted to do that-

void MoveTo(Vector3 newPos)
    vector3 moveVector = newPos - transform.position;

Of course, like a normal move, it will check for collisions along the way, which means that you can’t use this to move through walls! Is there any reason why you can’t just cheat it using

transform.position = newPos;