blob: 50d043ff408e2bcba7a53f1b23fc33a4a695c5fe (
plain)
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
|
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
[Serializable]
public class MotionCondition : SerializableCallback<bool> { }
[Serializable]
public class JointMotion
{
#region 序列化
public string desc;
public JointMotionInfo info;
public MotionCondition condition;
#endregion
#region 私有字段
public Rigidbody m_Rig;
#endregion
public void Animate(Rigidbody hip)
{
if (condition.target != null && condition.Invoke() == false)
return;
Vector3 dir = Vector3.zero;
if (info.direction == JointMotionInfo.MoveDirection.Swing)
{
dir = m_Rig.transform.right;
}
if (info.direction == JointMotionInfo.MoveDirection.FollowHip)
{
dir = hip.velocity.normalized;
}
if (info.type == JointMotionInfo.MotionType.Torque)
{
m_Rig.AddTorque(dir * Time.deltaTime * info.forceMultiplier, ForceMode.Acceleration);
}
if (info.type == JointMotionInfo.MotionType.Force)
{
m_Rig.AddForce(dir * Time.deltaTime * info.forceMultiplier, ForceMode.Acceleration);
}
}
}
|