So like I said, I’m pretty much a beginner and I have a game idea that I want to use to learn continually on (to make the prototype it’ll be pretty basic, but as I go on I’ll just add more and more complex features).
Basically I was tying to figure out how I would go about writing a code for a moving system that allows the player to move around and turn (not only in direction but in the rotation of the player) gradually (an example being something like Harvest Moon Magical Melody: http://www.youtube.com/watch?v=cgL-LpWqrOs). The rotation is not only desired to make it look better but also because I wanted to add in a “tripping” possibility (kind of like in Animal Crossing City Folk now that I’m thinking about it) that will increase the chance of “tripping” when the ground is “wet” and also when the player turns (rotates) too quickly (such as changing rotation/direction more than 90 degrees in a second or half second possibly). I am not specifically familiar with C# syntax but I have meandered through some languages (I would post a sample code of this if only I was more familiar with the needed syntax).
Basically, you need to find a character with a tripping/falldown animation and a stand-up animation. You’re going to want to find an animation that has walking towards left and walking towards right/turning.
Integrate that with your character controller, character controller is good for most types of character motion. Best of all, it handles stairs.
Disable any X and Z movement while the character is on the ground. When they get up, enable the controls again. You’ll want an input script to work with movement, and animation. Try using a state machine to enable/disable the character controls. If your character is Unity4 Animation type you can use the new controller which is more powerful.
You’re going to need to evaluate early in the planning stage which type of animation controller you’re going to use. You’re also going to need to decide how you’re going to do the rotation, you’ll find some rotate towards functions in the unity reference. Your can handle the rotation directly into the transform, or you can handle it through the physics engine.
You can also use Unity’s character controller package as a reference, but it is pretty basic, unless you want to knock over some dominos with your character controller to test it out.
@GBCFraser thanks a lot for the input! Currently I’m creating a character in Blender (the basic character is down, but I haven’t gotten to animating it yet), can you further explain what you mean by Unity 4 Animation type? Or possibly just explain if I can still use it with my already made Blender mesh?
There are some other things in your response that I am not familiar with (state machine, physics engine), but I’ll look them up and if I’m still confused later come back and ask. Thanks again for the response! I’ll post some progress in a day or two
You’re going to want a finite state machine to control your animations.
Example:
public enum AnimationStates {Idle, Walking, Running, Jumping, FallDown};
public AnimationStates state = AnimationStates.Idle;
void update(){
if (state == AnimationStates.Idle)
{
RunIdle();
}
else if(state == AnimationStates.Walking)
{
RunWalking();
}
// and so on....
}
This isn’t the most powerful way to control animations but it works for my needs.
Stay tuned, I’ll add some stuff about Unity 4 Animations…
Mecanim is another type of animation controller:
http://unity3d.com/unity/animation/
Its more powerful because you can apply transformations to your movement, you can also have the animation control the character movement, and NOT math, physics, or pseudo-physics.
Its powerful, if you’re willing to get the quality animations to handle it. Miximo has some free ones, but they charge alot for the Mecanim animations. You’re going to need to create the rigging to Mecanim standards or you’re going to have to adjust the bones/rigging manually.
Mecamin can handle AAA game animation stuff, for example if your character is tired, you can add the panting animation onto the run cycle. It also has tools to create smoother transitions between animations, and not a jerky transition, and animations can work directly from variables. I’ve also seen it used to reverse the animations, so you can create a walk backwards cycle by running the animation in reverse. Mecanim handles animations more visually with less code. You can also apply animation masks, for example you can apply the shooting animation to the arms, while the walking animation continues on the legs.
If you’re using Unity3 you can goto the animation window and apply animation events etcetera, it also should work with Mecanim too. This is useful if you want an event in the animation such as.
Detect_sword_hit();
Any you don’t want it to work as the character starts to swing the sword, and you don’t want to fart around with find the right frame in the animation.
Your issue is going to be that Unity3 Animation and unity 4 animation aren’t too compatible IMO.
If you’re working from a simple animation list, like I am, I’d work from Unity3.