-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHandMove.cs
64 lines (55 loc) · 1.9 KB
/
HandMove.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace weaponMaster
{
public class HandMove : MonoBehaviour
{
public Transform targetRight;
public Transform targetLeft;
public Transform lookTarget;
Animator m_anim;
[Range(0, 1)]
public float weight = 1.0f;
public float speed;
public enum Part
{
RightHand,
LeftHand,
TwoHand,
RightFoot,
LeftFoot,
TwoFoot
}
public Part part;
void Start()
{
m_anim = GetComponent<Animator>();
}
private void OnAnimatorIK(int layerIndex)
{
if (part == Part.RightHand) {
m_anim.SetIKPosition(AvatarIKGoal.RightHand, targetRight.position);
m_anim.SetIKPositionWeight(AvatarIKGoal.RightHand, weight);
m_anim.SetLookAtPosition(lookTarget.position);
m_anim.SetLookAtWeight(weight);
}
else if (part == Part.LeftHand)
{
m_anim.SetIKPosition(AvatarIKGoal.LeftHand, targetLeft.position);
m_anim.SetIKPositionWeight(AvatarIKGoal.LeftHand, weight);
m_anim.SetLookAtPosition(lookTarget.position);
m_anim.SetLookAtWeight(weight);
}
else if (part == Part.TwoHand)
{
m_anim.SetIKPosition(AvatarIKGoal.RightHand, targetRight.position);
m_anim.SetIKPositionWeight(AvatarIKGoal.RightHand, weight);
m_anim.SetIKPosition(AvatarIKGoal.LeftHand, targetLeft.position);
m_anim.SetIKPositionWeight(AvatarIKGoal.LeftHand, weight);
m_anim.SetLookAtPosition(lookTarget.position);
m_anim.SetLookAtWeight(weight);
}
}
}
}