Unity 4: Mecanim Animation Tutorial

Научился сам? Помоги начинающему.

Unity 4: Mecanim Animation Tutorial

Сообщение waruiyume 09 сен 2012, 08:39

Аватара пользователя
waruiyume
Адепт
 
Сообщения: 6143
Зарегистрирован: 30 окт 2010, 05:03
Откуда: Ростов на Дону

Re: Unity 4: Preorder Mecanim Beta Tutorial

Сообщение Woolf 09 сен 2012, 11:40

Больше всего доставило то, что теперь анимация двигает контроллер


Больше всего доставило, что у меня из-за этого рыба утягивала рыбака в воду. Пришлось контролировать положение рыбака дополнительно. И с анимивентами они перемудрили.. Как их сейчас делать - хз, я сделал через curves но это костыль страшный.

А вообще, mecanim - это просто!
Изображение
Разработчик theFisherOnline - там, где клюёт
Разработчик Atom Fishing II - Первая 3D MMO про рыбалку
Разработчик Atom Fishing - Рыбалка на поплавок, донку, нахлыст, блесну в постъядерный период.
Аватара пользователя
Woolf
Адепт
 
Сообщения: 7179
Зарегистрирован: 02 мар 2009, 16:59

Re: Unity 4: Preorder Mecanim Beta Tutorial

Сообщение waruiyume 09 сен 2012, 17:32

Пришлось контролировать положение рыбака дополнительно.

Изображение
Это не помогло?
Аватара пользователя
waruiyume
Адепт
 
Сообщения: 6143
Зарегистрирован: 30 окт 2010, 05:03
Откуда: Ростов на Дону

Re: Unity 4: Preorder Mecanim Beta Tutorial

Сообщение Woolf 09 сен 2012, 17:41

неа, не помогает.. хотя может это баг пока.. он там сдвигается на пару сантиметров в минуту, но когда долго ловишь - падает с мостка в воду))
Разработчик theFisherOnline - там, где клюёт
Разработчик Atom Fishing II - Первая 3D MMO про рыбалку
Разработчик Atom Fishing - Рыбалка на поплавок, донку, нахлыст, блесну в постъядерный период.
Аватара пользователя
Woolf
Адепт
 
Сообщения: 7179
Зарегистрирован: 02 мар 2009, 16:59

Re: Unity 4: Preorder Mecanim Beta Tutorial

Сообщение cinema4d 27 ноя 2012, 11:48

А по скрипту не поможете?? плз (c#)
а то видео в привате успел только накидать анимацию в контроль
cinema4d
UNец
 
Сообщения: 6
Зарегистрирован: 25 ноя 2012, 18:36

Re: Unity 4: Mecanim Animation Tutorial

Сообщение waruiyume 28 ноя 2012, 06:16

Поменял видео на актуальное.
Аватара пользователя
waruiyume
Адепт
 
Сообщения: 6143
Зарегистрирован: 30 окт 2010, 05:03
Откуда: Ростов на Дону

Re: Unity 4: Mecanim Animation Tutorial

Сообщение NOVA 22 дек 2012, 09:19

Неплохо было бы иметь это видео на жёстком. Но на ютьюб защита походу. Не скачать. Никто не видел файла?
Аватара пользователя
NOVA
Адепт
 
Сообщения: 1741
Зарегистрирован: 17 май 2011, 11:45
Откуда: Дядя Саша from Mother Russia

Re: Unity 4: Mecanim Animation Tutorial

Сообщение Kayler 22 дек 2012, 09:49

NOVA писал(а):Неплохо было бы иметь это видео на жёстком. Но на ютьюб защита походу. Не скачать. Никто не видел файла?

Скачать 1024 качество
Скачать 720 качество
Аватара пользователя
Kayler
Адепт
 
Сообщения: 1038
Зарегистрирован: 25 авг 2010, 23:49
Откуда: Чувашия

Re: Unity 4: Mecanim Animation Tutorial

Сообщение NOVA 08 янв 2013, 12:23

Kayler писал(а):
NOVA писал(а):Неплохо было бы иметь это видео на жёстком. Но на ютьюб защита походу. Не скачать. Никто не видел файла?

Скачать 1024 качество
Скачать 720 качество

Скрытый текст:
Изображение
Аватара пользователя
NOVA
Адепт
 
Сообщения: 1741
Зарегистрирован: 17 май 2011, 11:45
Откуда: Дядя Саша from Mother Russia

Re: Unity 4: Mecanim Animation Tutorial

Сообщение freeaces 06 фев 2013, 19:02

http://westbyte.com/dm/index.phtml?page=download Download master спокойно качает видео с простой ссылки на ютуб.
freeaces
UNец
 
Сообщения: 1
Зарегистрирован: 06 фев 2013, 18:59

Re: Unity 4: Mecanim Animation Tutorial

Сообщение Tasimov 11 фев 2013, 14:28

Всем привет,прошел урок,получилось,но возник вопрос ,как задать скорость передвижения персонажу? не анимации а именно передвижение самого персонажа по земле.

Вот в коде не могу найти где он задает скорость:
Скрытый текст:
Синтаксис:
Используется javascript
using UnityEngine;
using System.Collections;

// Require these components when using this script
[RequireComponent(typeof (Animator))]
[RequireComponent(typeof (CapsuleCollider))]
[RequireComponent(typeof (Rigidbody))]
public class BotControlScript : MonoBehaviour
{
        [System.NonSerialized]                                 
        public float lookWeight;                                        // the amount to transition when using head look
       
        [System.NonSerialized]
        public Transform enemy;                                         // a transform to Lerp the camera to during head look
       
        public float animSpeed = 1.5f;                          // a public setting for overall animator animation speed
        public float lookSmoother = 3f;                         // a smoothing setting for camera motion
        public bool useCurves;                                          // a setting for teaching purposes to show use of curves

       
        private Animator anim;                                                  // a reference to the animator on the character
        private AnimatorStateInfo currentBaseState;                     // a reference to the current state of the animator, used for base layer
        private AnimatorStateInfo layer2CurrentState;   // a reference to the current state of the animator, used for layer 2
        private CapsuleCollider col;                                    // a reference to the capsule collider of the character
       

        static int idleState = Animator.StringToHash("Base Layer.Idle");       
        static int locoState = Animator.StringToHash("Base Layer.Locomotion");                  // these integers are references to our animator's states
        static int jumpState = Animator.StringToHash("Base Layer.Jump");                                // and are used to check state for various actions to occur
        static int jumpDownState = Animator.StringToHash("Base Layer.JumpDown");                // within our FixedUpdate() function below
        static int fallState = Animator.StringToHash("Base Layer.Fall");
        static int rollState = Animator.StringToHash("Base Layer.Roll");
        static int waveState = Animator.StringToHash("Layer2.Wave");
       

        void Start ()
        {
                // initialising reference variables
                anim = GetComponent<Animator>&#40;&#41;;                                         
                col = GetComponent<CapsuleCollider>&#40;&#41;;                         
                enemy = GameObject.Find&#40;"Enemy"&#41;.transform;    
                if&#40;anim.layerCount ==2&#41;
                        anim.SetLayerWeight&#40;1, 1&#41;;
        }
       
       
        void FixedUpdate &#40;&#41;
        {
                float h = Input.GetAxis&#40;"Horizontal"&#41;;                          // setup h variable as our horizontal input axis
                float v = Input.GetAxis&#40;"Vertical"&#41;;                            // setup v variables as our vertical input axis
                anim.SetFloat&#40;"Speed", v&#41;;                                                      // set our animator&#39;s float parameter &#39;Speed&#39; equal to the vertical input axis                             
                anim.SetFloat&#40;"Direction", h&#41;;                                          // set our animator&#39;s float parameter &#39;Direction&#39; equal to the horizontal input axis               
                anim.speed = animSpeed;                                                         // set the speed of our animator to the public variable &#39;animSpeed&#39;
                anim.SetLookAtWeight&#40;lookWeight&#41;;                                       // set the Look At Weight - amount to use look at IK vs using the head&#39;s animation
                currentBaseState = anim.GetCurrentAnimatorStateInfo&#40;0&#41;; // set our currentState variable to the current state of the Base Layer &#40;0&#41; of animation
               
                if&#40;anim.layerCount ==2&#41;        
                        layer2CurrentState = anim.GetCurrentAnimatorStateInfo&#40;1&#41;;       // set our layer2CurrentState variable to the current state of the second Layer &#40;1&#41; of animation
               
               
                // LOOK AT ENEMY
               
                // if we hold Alt..
                if&#40;Input.GetButton&#40;"Fire2"&#41;&#41;
                {
                        // ...set a position to look at with the head, and use Lerp to smooth the look weight from animation to IK &#40;see line 54&#41;
                        anim.SetLookAtPosition&#40;enemy.position&#41;;
                        lookWeight = Mathf.Lerp&#40;lookWeight,1f,Time.deltaTime*lookSmoother&#41;;
                }
                // else, return to using animation for the head by lerping back to 0 for look at weight
                else
                {
                        lookWeight = Mathf.Lerp&#40;lookWeight,0f,Time.deltaTime*lookSmoother&#41;;
                }
               
                // STANDARD JUMPING
               
                // if we are currently in a state called Locomotion &#40;see line 25&#41;, then allow Jump input &#40;Space&#41; to set the Jump bool parameter in the Animator to true
                if &#40;currentBaseState.nameHash == locoState&#41;
                {
                        if&#40;Input.GetButtonDown&#40;"Jump"&#41;&#41;
                        {
                                anim.SetBool&#40;"Jump", true&#41;;
                        }
                }
               
                // if we are in the jumping state...
                else if&#40;currentBaseState.nameHash == jumpState&#41;
                {
                        //  ..and not still in transition..
                        if&#40;!anim.IsInTransition&#40;0&#41;&#41;
                        {
                                if&#40;useCurves&#41;
                                        // ..set the collider height to a float curve in the clip called ColliderHeight
                                        col.height = anim.GetFloat&#40;"ColliderHeight"&#41;;
                               
                                // reset the Jump bool so we can jump again, and so that the state does not loop
                                anim.SetBool&#40;"Jump", false&#41;;
                        }
                       
                        // Raycast down from the center of the character..
                        Ray ray = new Ray&#40;transform.position + Vector3.up, -Vector3.up&#41;;
                        RaycastHit hitInfo = new RaycastHit&#40;&#41;;
                       
                        if &#40;Physics.Raycast&#40;ray, out hitInfo&#41;&#41;
                        {
                                // ..if distance to the ground is more than 1.75, use Match Target
                                if &#40;hitInfo.distance > 1.75f&#41;
                                {
                                       
                                        // MatchTarget allows us to take over animation and smoothly transition our character towards a location - the hit point from the ray.
                                        // Here we&#39;re telling the Root of the character to only be influenced on the Y axis &#40;MatchTargetWeightMask&#41; and only occur between 0.35 and 0.5
                                        // of the timeline of our animation clip
                                        anim.MatchTarget&#40;hitInfo.point, Quaternion.identity, AvatarTarget.Root, new MatchTargetWeightMask&#40;new Vector3&#40;0, 1, 0&#41;, 0&#41;, 0.35f, 0.5f&#41;;
                                }
                        }
                }
               
               
                // JUMP DOWN AND ROLL
               
                // if we are jumping down, set our Collider&#39;s Y position to the float curve from the animation clip -
                // this is a slight lowering so that the collider hits the floor as the character extends his legs
                else if &#40;currentBaseState.nameHash == jumpDownState&#41;
                {
                        col.center = new Vector3&#40;0, anim.GetFloat&#40;"ColliderY"&#41;, 0&#41;;
                }
               
                // if we are falling, set our Grounded boolean to true when our character&#39;s root
                // position is less that 0.6, this allows us to transition from fall into roll and run
                // we then set the Collider&#39;s Height equal to the float curve from the animation clip
                else if &#40;currentBaseState.nameHash == fallState&#41;
                {
                        col.height = anim.GetFloat&#40;"ColliderHeight"&#41;;
                }
               
                // if we are in the roll state and not in transition, set Collider Height to the float curve from the animation clip
                // this ensures we are in a short spherical capsule height during the roll, so we can smash through the lower
                // boxes, and then extends the collider as we come out of the roll
                // we also moderate the Y position of the collider using another of these curves on line 128
                else if &#40;currentBaseState.nameHash == rollState&#41;
                {
                        if&#40;!anim.IsInTransition&#40;0&#41;&#41;
                        {
                                if&#40;useCurves&#41;
                                        col.height = anim.GetFloat&#40;"ColliderHeight"&#41;;
                               
                                col.center = new Vector3&#40;0, anim.GetFloat&#40;"ColliderY"&#41;, 0&#41;;
                               
                        }
                }
                // IDLE
               
                // check if we are at idle, if so, let us Wave!
                else if &#40;currentBaseState.nameHash == idleState&#41;
                {
                        if&#40;Input.GetButtonUp&#40;"Jump"&#41;&#41;
                        {
                                anim.SetBool&#40;"Wave", true&#41;;
                        }
                }
                // if we enter the waving state, reset the bool to let us wave again in future
                if&#40;layer2CurrentState.nameHash == waveState&#41;
                {
                        anim.SetBool&#40;"Wave", false&#41;;
                }
        }
Tasimov
UNец
 
Сообщения: 48
Зарегистрирован: 24 сен 2011, 14:19

Re: Unity 4: Mecanim Animation Tutorial

Сообщение NOVA 17 сен 2013, 11:08

А что такое Atomic, товарищи?
Аватара пользователя
NOVA
Адепт
 
Сообщения: 1741
Зарегистрирован: 17 май 2011, 11:45
Откуда: Дядя Саша from Mother Russia

Re: Unity 4: Mecanim Animation Tutorial

Сообщение waruiyume 17 сен 2013, 11:21

Такой трансижен, не может быть прерван, другим трансиженом.
Аватара пользователя
waruiyume
Адепт
 
Сообщения: 6143
Зарегистрирован: 30 окт 2010, 05:03
Откуда: Ростов на Дону

Re: Unity 4: Mecanim Animation Tutorial

Сообщение NOVA 17 сен 2013, 13:16

waruiyume писал(а):Такой трансижен, не может быть прерван, другим трансиженом.

Тот, у которого стоит стойкое условие и выход по времени, если я правильно понял.
Аватара пользователя
NOVA
Адепт
 
Сообщения: 1741
Зарегистрирован: 17 май 2011, 11:45
Откуда: Дядя Саша from Mother Russia

Re: Unity 4: Mecanim Animation Tutorial

Сообщение seaman 17 сен 2013, 17:25

Неправильно.
seaman
Адепт
 
Сообщения: 8352
Зарегистрирован: 24 янв 2011, 12:32
Откуда: Самара


Вернуться в Уроки

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 2