Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Last active November 14, 2018 02:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsubaki/4c0e479519b01f2af857f3f96ee6a374 to your computer and use it in GitHub Desktop.
Save tsubaki/4c0e479519b01f2af857f3f96ee6a374 to your computer and use it in GitHub Desktop.
MatchTargetのサンプル
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Jump : StateMachineBehaviour {
[SerializeField] AvatarTarget targetBodyPart = AvatarTarget.Root;
[SerializeField, Range(0, 1)] float start = 0, end = 1;
[HeaderAttribute("match target")]
public Vector3 matchPosition; // 指定パーツが到達して欲しい座標
public Quaternion matchRotation; // 到達して欲しい回転
[HeaderAttribute("Weights")]
public Vector3 positionWeight = Vector3.one; // matchPositionに与えるウェイト。(1,1,1)で自由、(0,0,0)で移動できない。e.g. (0,0,1)で前後のみ
public float rotationWeight = 0; // 回転に与えるウェイト。
private MatchTargetWeightMask weightMask;
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
weightMask = new MatchTargetWeightMask (positionWeight, rotationWeight);
}
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
animator.MatchTarget (matchPosition, matchRotation, targetBodyPart, weightMask, start, end);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment