Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am new to Unity3D and I am going to develop a simple animation application. There is a human character and there are three button Eg:- "jump", "down" , "roll", I want to bind the animation files with the human character once the player presses the corresponding button. I need your help to know that what are the steps that I need to follow...let me know if anyone has good reference, thank you very much...

share|improve this question
2  
What have you tried so far? –  thalador Jun 3 '13 at 6:26
    
The best place to go isn't StackExchange, but UnityAnswers. That is a much better website. Specifically, here is the answer to your question. answers.unity3d.com/questions/17090/… –  user31435 Jun 3 '13 at 6:36
    
Thanks all... i solved the problem. –  Tharindu Jun 5 '13 at 6:11

1 Answer 1

up vote 5 down vote accepted

First off: There is the unity scripting reference, it is the best tool when creating anything with Unity3d.

http://docs.unity3d.com/Documentation/ScriptReference/

http://docs.unity3d.com/Documentation/ScriptReference/Input.GetKeyUp.html For input keys read about the Input.GetKeyUp - Returns true during the frame the user releases the key identified by the key KeyCode enum parameter. If you want to have the player walk straight you will want to use the function Input.GetKeyDown

For creating basic character movement, go through official unity3d guides and play around the unity basic assets, which contain the two different character controllers.

/// This script moves the character controller forward 
/// and sideways based on the arrow keys.
/// It also jumps when pressing space.
/// Make sure to attach a character controller to the same game object.
/// It is recommended that you make only one call to Move or SimpleMove per frame.    
var speed : float = 6.0;
var jumpSpeed : float = 8.0;
var gravity : float = 20.0;
private var moveDirection : Vector3 = Vector3.zero;
function Update() {
    var controller : CharacterController = GetComponent(CharacterController);
    if (controller.isGrounded) {
        // We are grounded, so recalculate
        // move direction directly from axes
        moveDirection = Vector3(Input.GetAxis("Horizontal"), 0,
                                Input.GetAxis("Vertical"));
        moveDirection = transform.TransformDirection(moveDirection);
        moveDirection *= speed;

        if (Input.GetButton ("Jump")) {
            moveDirection.y = jumpSpeed;
        }
    }
    // Apply gravity
    moveDirection.y -= gravity * Time.deltaTime;

    // Move the controller
    controller.Move(moveDirection * Time.deltaTime);
}

http://docs.unity3d.com/Documentation/ScriptReference/CharacterController.Move.html

For tutorials I have once found an entire tutorial, how to script a unity3d rpg game in C# from scratch.

http://www.youtube.com/watch?v=H7UF3wga5W0

http://Digitaltutors.com have some awesome tutorials on unity covering all basics. (They are paid)

http://www.youtube.com/user/BurgZergArcade?feature=watch You could start by watching some of the vids on this channel, they are free and there are over 50 hours of C# scripting lessons, they youtuber explains carefully everything.

Good luck

EDIT:

I have missed the part where you wanted to make an "Animation", so if you want to move your character around you should use the physic vector3 functions that I mentioned before. In case you meant playing back a pre-made animation from some external 3d graphic program you should take the animation from the project view drag and drop it on the item that is supposed to be animated. The function is called Animation.Play

http://docs.unity3d.com/Documentation/ScriptReference/Animation.Play.html

 // Plays the walk animation - stops all other animations in the same layer
    animation.Play("walk");
    // Plays the walk animation - stops all other animations
    animation.Play("walk", PlayMode.StopAll);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.