|
@@ -23,8 +23,8 @@ public class MoveCharacter : Character
|
|
|
public float hurtChangeVelocity = 1;
|
|
public float hurtChangeVelocity = 1;
|
|
|
|
|
|
|
|
[Header("新增漂浮效果参数")]
|
|
[Header("新增漂浮效果参数")]
|
|
|
- public float maxSpeed = 15; //上升最大速度
|
|
|
|
|
- public float minSpeed = 6; //上升最小速度
|
|
|
|
|
|
|
+ public float maxTime = 15; //上升最大耗时
|
|
|
|
|
+ public float minTime = 6; //上升最小耗时
|
|
|
public float maxHeight = 12; //最大上升高度
|
|
public float maxHeight = 12; //最大上升高度
|
|
|
public float minHeight = 7; //最小上升高度
|
|
public float minHeight = 7; //最小上升高度
|
|
|
|
|
|
|
@@ -35,12 +35,14 @@ public class MoveCharacter : Character
|
|
|
|
|
|
|
|
private float curTime; //漂浮已进行时长
|
|
private float curTime; //漂浮已进行时长
|
|
|
private float height; //漂浮高度
|
|
private float height; //漂浮高度
|
|
|
- private float floatSpeed; //漂浮速度
|
|
|
|
|
|
|
+ private float riseTime; //上升时间
|
|
|
private float curHeight; //当前所在高度
|
|
private float curHeight; //当前所在高度
|
|
|
private float rotateSpeed; //旋转速度
|
|
private float rotateSpeed; //旋转速度
|
|
|
private float rotateDir; //旋转方向
|
|
private float rotateDir; //旋转方向
|
|
|
|
|
|
|
|
private Vector3 origPos; //初始位置
|
|
private Vector3 origPos; //初始位置
|
|
|
|
|
+ private float rise = 1;
|
|
|
|
|
+ private float down = -1;
|
|
|
private Vector3 oneClockwise = new Vector3(0, 0, 1);
|
|
private Vector3 oneClockwise = new Vector3(0, 0, 1);
|
|
|
private Vector3 oneCounterClockwise = new Vector3(0, 0, -1);
|
|
private Vector3 oneCounterClockwise = new Vector3(0, 0, -1);
|
|
|
|
|
|
|
@@ -50,15 +52,15 @@ public class MoveCharacter : Character
|
|
|
|
|
|
|
|
public void FloatStateOn()
|
|
public void FloatStateOn()
|
|
|
{
|
|
{
|
|
|
- maxSpeed = 15;
|
|
|
|
|
- minSpeed = 2;
|
|
|
|
|
|
|
+ maxTime = 1.5f;
|
|
|
|
|
+ minTime = 0.1f;
|
|
|
maxHeight = 9;
|
|
maxHeight = 9;
|
|
|
minHeight = 4;
|
|
minHeight = 4;
|
|
|
|
|
|
|
|
floatTime = 20;
|
|
floatTime = 20;
|
|
|
ChangeState(CharacterState.Rise);
|
|
ChangeState(CharacterState.Rise);
|
|
|
floatState = 1;
|
|
floatState = 1;
|
|
|
- floatSpeed = Random.Range(minSpeed, maxSpeed);
|
|
|
|
|
|
|
+ riseTime = Random.Range(minTime, maxTime);
|
|
|
origPos = transform.position;
|
|
origPos = transform.position;
|
|
|
curHeight = origPos.y;
|
|
curHeight = origPos.y;
|
|
|
curTime = 0;
|
|
curTime = 0;
|
|
@@ -80,9 +82,9 @@ public class MoveCharacter : Character
|
|
|
RotateSelf();
|
|
RotateSelf();
|
|
|
curTime += Time.deltaTime;
|
|
curTime += Time.deltaTime;
|
|
|
aniCollider.Play("Rise", 0, 0);
|
|
aniCollider.Play("Rise", 0, 0);
|
|
|
- curHeight += floatSpeed * Time.deltaTime;
|
|
|
|
|
|
|
+ curHeight = Mathf.SmoothDamp(curHeight, height, ref rise, riseTime);
|
|
|
transform.position = new Vector3(origPos.x, curHeight, origPos.z);
|
|
transform.position = new Vector3(origPos.x, curHeight, origPos.z);
|
|
|
- if (curHeight >= height)
|
|
|
|
|
|
|
+ if (curHeight >= height - 0.02f)
|
|
|
{
|
|
{
|
|
|
floatState = 2;
|
|
floatState = 2;
|
|
|
ChangeState(CharacterState.Float);
|
|
ChangeState(CharacterState.Float);
|