You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
2.5 KiB
64 lines
2.5 KiB
using UnityEngine; |
|
using AX.TrackRecord; |
|
using AX.MessageSystem; |
|
|
|
public class lati15Control : BaseLadder |
|
{ |
|
float TIMESTAMP = 1.0f;//经过几秒判断一次 |
|
float timer = 0f;//计时器,默认为0 |
|
float THRESHOLD = 0.2f;//判断是否移动/旋转的容错阈值 |
|
//伸长/缩短拉梯 |
|
float lastFrame1_position_y; |
|
float lastFrame2_position_y; |
|
float lastFrame3_position_y; |
|
|
|
float currentFrame1_position_y; |
|
float currentFrame2_position_y; |
|
float currentFrame3_position_y; |
|
//拉梯前俯后仰 |
|
float lastFrame_rotate_x; |
|
|
|
float currentFrame_rotate_x; |
|
|
|
void Start() { |
|
timer = TIMESTAMP; |
|
lastFrame1_position_y = ladderPart1.gameObject.transform.localPosition.y; |
|
lastFrame2_position_y = ladderPart2.gameObject.transform.localPosition.y; |
|
lastFrame3_position_y = ladderPart3.gameObject.transform.localPosition.y; |
|
lastFrame_rotate_x = this.gameObject.transform.localEulerAngles.x; |
|
} |
|
public override void InitGameObject() |
|
{ |
|
ladderPart1= this.gameObject.transform.Find("LadderDown").gameObject; |
|
ladderPart2 = ladderPart1.transform.Find("LadderUp").gameObject; |
|
ladderPart3 = ladderPart2.transform.Find("LadderUp2").gameObject; |
|
} |
|
|
|
void Update() { |
|
if (timer > 0) |
|
{ |
|
timer -= Time.deltaTime; |
|
} |
|
else |
|
{ |
|
currentFrame1_position_y = ladderPart1.gameObject.transform.localPosition.y; |
|
currentFrame2_position_y = ladderPart2.gameObject.transform.localPosition.y; |
|
currentFrame3_position_y = ladderPart3.gameObject.transform.localPosition.y; |
|
currentFrame_rotate_x = this.gameObject.transform.localEulerAngles.x; |
|
if (Mathf.Abs(currentFrame1_position_y - lastFrame1_position_y) > THRESHOLD || |
|
Mathf.Abs(currentFrame2_position_y - lastFrame2_position_y) > THRESHOLD || |
|
Mathf.Abs(currentFrame3_position_y - lastFrame3_position_y) > THRESHOLD || |
|
Mathf.Abs(currentFrame_rotate_x - lastFrame_rotate_x) > THRESHOLD) { |
|
if (RecordManager.Instance.IsRecording) |
|
{ |
|
MessageDispatcher.SendMessage("RecordControlLatiEvent", (object)this.name); |
|
} |
|
} |
|
lastFrame1_position_y = currentFrame1_position_y; |
|
lastFrame2_position_y = currentFrame2_position_y; |
|
lastFrame3_position_y = currentFrame3_position_y; |
|
lastFrame_rotate_x = currentFrame_rotate_x; |
|
timer = TIMESTAMP; |
|
} |
|
} |
|
} |