Version: 2022.1
언어: 한국어
솔로 및 뮤트 기능
역운동학(IK)

타겟 매칭

게임에서는 캐릭터의 손이나 발이 특정 지점에 특정 순간에 닿는 방식으로 움직여야 하는 상황이 종종 발생합니다. 예를 들어 캐릭터가 징검다리를 뛰어 건너가는 경우 또는 공중에 있는 가로 기둥을 점프해서 붙잡아야 하는 경우 등이 있습니다.

You can use the Animator.MatchTarget function to handle this kind of situation. Imagine, for example, you want to arrange a situation where the character jumps onto a platform and you already have an animation clip for it called Jump Up. Firstly, you need to find the place in the animation clip at which the character is beginning to get off the ground, note in this case it is 14.1% or 0.141 into the animation clip in normalized time:

또한 캐릭터가 두 발로 막 착지하는 순간이 애니메이션 클립에서 어느 지점인지도 찾아야 하는데, 여기서는 78.0% 또는 0.78 지점입니다.

With this information, you can create a script that calls MatchTarget which you can attach to the model:

using UnityEngine;
using System;

[RequireComponent(typeof(Animator))]
public class TargetCtrl : MonoBehaviour {

    protected Animator animator;

    //the platform object in the scene
    public Transform jumpTarget = null;
    void Start () {
        animator = GetComponent<Animator>();
    }

    void Update () {
        if(animator) {
            if(Input.GetButton("Fire1"))         
                animator.MatchTarget(jumpTarget.position, jumpTarget.rotation, AvatarTarget.LeftFoot,
                                                       new MatchTargetWeightMask(Vector3.one, 1f), 0.141f, 0.78f);
        }       
    }
}


이 스크립트는 캐릭터를 움직여서 캐릭터가 현재 포지션에서 점프하여 목적지에 왼발로 착지하게 만들 것입니다. 명심할 점은 MatchTarget은 게임플레이 도중 적절한 시점에 호출되었을 때에만 보통 그럴싸한 결과가 나올 것이라는 점입니다.

솔로 및 뮤트 기능
역운동학(IK)
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961