Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Closeゲームの中でしばしば,キャラクターの手あるいは足が特定のところに特定のタイミングで着地することが発生します。例えば,キャラクターが飛び石をジャンプして越えていく必要があるかもしれないし,頭の上のビームをつかむ必要があるかもしれません。
このような状況に対応するにはAnimator.MatchTarget 関数 を使用することが出来ます。例えば,キャラクターが地面の上にジャンプして,すでに Jump Up というアニメーションクリップをすでに用意していたとします。これを実現するには,次のステップを行います:
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);
}
}
}
TargetCtrl.cs
) を作成して,MatchTarget に対するコールを,次のように行います: