I was somewhat tempted to use the CharacterMotor script, mainly because of the ease of having moving platforms and slopes, but man is this monstrosity daunting to look at. Compared to the old FPSwalker/FPSWalkerEnhanced, this script is orders of magnitude more complex - I can’t even begin to see where I would need to yank out pieces just to make it a 2D CharacterController ‘engine.’ Let alone all the other enhancements I’ve already added to FPSWalker (doublejump, walljumping, etc).
I’m really hoping there’ll be a tutorial related to this new script upon release of Unity 3, because this is almost like getting dropped into the deep end of the pool when you don’t even know what water IS.
As it is right now, at least for my current game, I’m going to stick with my highly altered FPSwalker script - maybe by the time I get to my next game, the CharacterMotor will have more documentation. It’s commented, but there seems to be a lot missing… Anyone have any hints as to how to attack this thing and tear it apart a bit?
Obviously? If you say so… I assume you’re talking about a script that is included in Standard Assets in U3?
I don’t know if it’ll help, but if it’s the same CharacterMotor script that was part of the Locomotion system, studying that project and its documentation may provide some insight.
Yeah, I suppose it’s not obvious at all if you haven’t seen anything about Unity 3 - it’s referenced in the changelog, which is how I discovered it.
Just looked at the CharacterMotor.cs included with the Locomotion System - definitely not the same script. The CharacterMotor script included with Unity 3 is javascript, for one, and a heck of a lot more complex:
CharacterMotor.js (U3) is 587 lines. FPSWalker, by comparison, is 29. CharacterMotor.cs (Locomotion System) is about 66 lines. FPSWalkerEnhanced, which is more compelx (and more robust) than the standard asset FPSWalker, is 154 lines, 28 of which are comments.
Just in terms of line count, CharacterMotor.js is about 20 times longer than FPSwalker.js - which makes it much harder to parse if you don’t have any sort of starting point to go from. As far as I can tell, the old FPSWalker isn’t included in the Unity 3 Standard Assets, either. And if CharacterMotor.js is somehow a very advanced and tweaked version of the FPSwalker script, it’s certainly not obvious from the code.
I guess my point to all this is that the learning curve for Unity 3 might be quite a bit steeper for those beginning with Unity 3 - not having any sort of simple Character control script to hack away at makes it much, much harder to just jump in and start making custom character behaviors.
I donno what the beta license dealy is, but if someone from the Unity gives me their OK, I’ll post the CharacterMotor.js script up here so you can compare it to the other CharacterController scripts from Unity 2.
it uses a lot of the same concepts from the scripts included with the locomotion project, but yeah it’s greatly expanded to support slopes and moving platforms.
unlike fpswalker, it uses a separate component to handle input and rotation, depending on the camera scheme you’re using. those pass a direction vector, inputMoveDirection, to CharacterMotor.js, which factors it into the movement simulation. i’m guessing from your first post you’re making a 2d sidescrolling platformer? to constrain it to 2d you’ll just have to write a new input/rotation component that changes (assuming your game moves from left to right) inputMoveDirection.x based on Input.GetAxis(“Horizontal”), and you can probably (maybe) just adapt the auto-rotate code from PlatformInputController.js to rotate the character. and to clamp the movement to 2d, make sure currentMovementOffset.z is always 0 before it gets run through controller.Move() in UpdateFunction() and when building your level make sure moving platforms don’t move on the z axis and slopes aren’t cantered on the y or z axis. adding new jumping behavior will be trickier, but not impossible. you’re going to want to look at ApplyGravityAndJumping (obviously) and OnControllerColliderHit (which grabs the normal for slope jumping - you’ll probably want to add some code to it to get the normal for wall jumping.)