提交撬棍的修改
This commit is contained in:
@@ -14887,7 +14887,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!224 &1493993205
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -18812,7 +18812,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!224 &1816976208
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -17,7 +17,7 @@ public class Crowbar : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragH
|
||||
public bool IsInDialogue { get; set; } = false;
|
||||
|
||||
private Vector3 startPosition;
|
||||
private Quaternion startRotation;
|
||||
private Quaternion startRotation= Quaternion.Euler(0f, 0f, -225f);
|
||||
private bool isInserted = false;
|
||||
private Vector3 lastMousePosition;
|
||||
private float progress = 0f;
|
||||
@@ -67,12 +67,15 @@ public void OnDrag(PointerEventData eventData)
|
||||
|
||||
if (isInserted)
|
||||
{
|
||||
float deltaY = Input.mousePosition.y - lastMousePosition.y;
|
||||
progress = Mathf.Clamp01(progress+deltaY * Time.deltaTime);
|
||||
float deltaY = lastMousePosition.y - Input.mousePosition.y;
|
||||
lastMousePosition = Input.mousePosition; // 更新 lastMousePosition
|
||||
|
||||
// 计算插入旋转和插入旋转+35度之间的插值
|
||||
progress += deltaY*0.3f * Time.deltaTime;
|
||||
progress = Mathf.Clamp01(progress); // 确保 progress 不会小于0
|
||||
|
||||
// 计算插入旋转和插入旋转-45度之间的插值
|
||||
float startAngle = crowbarSocket.transform.eulerAngles.z;
|
||||
float endAngle = startAngle - 45f;
|
||||
float endAngle = startAngle + 40f;
|
||||
float currentAngle = Mathf.Lerp(startAngle, endAngle, progress);
|
||||
|
||||
// 更新撬棍的旋转角度
|
||||
@@ -83,7 +86,6 @@ public void OnDrag(PointerEventData eventData)
|
||||
// 触发撬动完成的逻辑
|
||||
Debug.Log("Crowbar action completed.");
|
||||
isPryingCompleted = true;
|
||||
//ResetCrowbar();
|
||||
ResetCrowbar();
|
||||
}
|
||||
}
|
||||
@@ -131,14 +133,14 @@ public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
//isInserted = false;
|
||||
progress = 0f;
|
||||
crowbarVisual.rotation = startRotation;
|
||||
crowbarVisual.rotation = Quaternion.Euler(0f, 0f, 180f);
|
||||
}
|
||||
private void ResetCrowbar()
|
||||
{
|
||||
isInserted=false;
|
||||
progress = 0f;
|
||||
crowbarVisual.rotation = startRotation;
|
||||
isPryingCompleted = false;
|
||||
//isPryingCompleted = false;
|
||||
transform.DOMove(crowbarInPosition.position, 0.1f);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user