This commit is contained in:
parent
08df50f0cf
commit
451e9b0435
File diff suppressed because it is too large
Load Diff
|
@ -38,7 +38,7 @@ RenderSettings:
|
||||||
m_ReflectionIntensity: 1
|
m_ReflectionIntensity: 1
|
||||||
m_CustomReflection: {fileID: 0}
|
m_CustomReflection: {fileID: 0}
|
||||||
m_Sun: {fileID: 0}
|
m_Sun: {fileID: 0}
|
||||||
m_IndirectSpecularColor: {r: 0.1825844, g: 0.22546011, b: 0.29071727, a: 1}
|
m_IndirectSpecularColor: {r: 0.18258438, g: 0.22546011, b: 0.29071727, a: 1}
|
||||||
m_UseRadianceAmbientProbe: 0
|
m_UseRadianceAmbientProbe: 0
|
||||||
--- !u!157 &3
|
--- !u!157 &3
|
||||||
LightmapSettings:
|
LightmapSettings:
|
||||||
|
@ -140,7 +140,7 @@ GameObject:
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 0
|
||||||
--- !u!81 &562157362
|
--- !u!81 &562157362
|
||||||
AudioListener:
|
AudioListener:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -299,8 +299,65 @@ Transform:
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 1
|
m_RootOrder: 2
|
||||||
m_LocalEulerAnglesHint: {x: 20.712, y: 91.21, z: 35.743}
|
m_LocalEulerAnglesHint: {x: 20.712, y: 91.21, z: 35.743}
|
||||||
|
--- !u!1001 &876751123
|
||||||
|
PrefabInstance:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Modification:
|
||||||
|
m_TransformParent: {fileID: 0}
|
||||||
|
m_Modifications:
|
||||||
|
- target: {fileID: 2399593117452945565, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3}
|
||||||
|
propertyPath: m_Name
|
||||||
|
value: Player
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3}
|
||||||
|
propertyPath: m_RootOrder
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.y
|
||||||
|
value: 1.01
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3}
|
||||||
|
propertyPath: m_LocalPosition.z
|
||||||
|
value: 7.79
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.w
|
||||||
|
value: 0.7071068
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.y
|
||||||
|
value: 0.7071068
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3}
|
||||||
|
propertyPath: m_LocalRotation.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.x
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.y
|
||||||
|
value: 90
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 2399593117452945566, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3}
|
||||||
|
propertyPath: m_LocalEulerAnglesHint.z
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
m_RemovedComponents: []
|
||||||
|
m_SourcePrefab: {fileID: 100100000, guid: 86a8666f9623b6b46b8f4b860a11546f, type: 3}
|
||||||
--- !u!1 &1677042732
|
--- !u!1 &1677042732
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -320,7 +377,7 @@ GameObject:
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 0
|
||||||
--- !u!81 &1677042733
|
--- !u!81 &1677042733
|
||||||
AudioListener:
|
AudioListener:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -385,7 +442,7 @@ Transform:
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 2
|
m_RootOrder: 3
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 90, z: 0}
|
||||||
--- !u!114 &1677042736
|
--- !u!114 &1677042736
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
|
@ -527,7 +584,7 @@ Transform:
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 4
|
m_RootOrder: 5
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1001 &2135612827
|
--- !u!1001 &2135612827
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
|
|
|
@ -1,111 +1,111 @@
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class CraneController : MonoBehaviour
|
public class CraneController : MonoBehaviour
|
||||||
{
|
{
|
||||||
public static CraneController Instance;
|
public static CraneController Instance;
|
||||||
[Header("物体")]
|
[Header("物体")]
|
||||||
public Transform bridge; // 横杆
|
public Transform bridge; // 横杆
|
||||||
public Transform hook; // 滑轮
|
public Transform hook; // 滑轮
|
||||||
public SkinnedMeshRenderer hookRenderer;//吊钩
|
public SkinnedMeshRenderer hookRenderer;//吊钩
|
||||||
|
|
||||||
[Header("移动速度")]
|
[Header("移动速度")]
|
||||||
[Range(1, 10)]
|
[Range(1, 10)]
|
||||||
public float bridgeSpeed = 5f; // 横杆移动速度
|
public float bridgeSpeed = 5f; // 横杆移动速度
|
||||||
[Range(1, 10)]
|
[Range(1, 10)]
|
||||||
public float hookSpeed = 5f; // 滑轮移动速度
|
public float hookSpeed = 5f; // 滑轮移动速度
|
||||||
|
|
||||||
public float blendShapeSpeed = 30f;
|
public float blendShapeSpeed = 30f;
|
||||||
|
|
||||||
[Header("移动范围限制 (Z轴)")]
|
[Header("移动范围限制 (Z轴)")]
|
||||||
[Range(-1, -20)]
|
[Range(-1, -20)]
|
||||||
public float bridgeMinZ = -5f;
|
public float bridgeMinZ = -5f;
|
||||||
[Range(1, 20)]
|
[Range(1, 20)]
|
||||||
public float bridgeMaxZ = 5f;
|
public float bridgeMaxZ = 5f;
|
||||||
[Range(-1, 5)]
|
[Range(-1, 5)]
|
||||||
public float hookMinZ = -3f;
|
public float hookMinZ = -3f;
|
||||||
[Range(1, 5)]
|
[Range(1, 5)]
|
||||||
public float hookMaxZ = 3f;
|
public float hookMaxZ = 3f;
|
||||||
|
|
||||||
[Header("BlendShape设置")]
|
[Header("BlendShape设置")]
|
||||||
public int hookBlendShapeIndex = 0; // BlendShape索引(通常是0)
|
public int hookBlendShapeIndex = 0; // BlendShape索引(通常是0)
|
||||||
public float minBlendShapeValue = 0f; // 吊钩收起
|
public float minBlendShapeValue = 0f; // 吊钩收起
|
||||||
public float maxBlendShapeValue = 100f; // 吊钩放下
|
public float maxBlendShapeValue = 100f; // 吊钩放下
|
||||||
|
|
||||||
private float currentBlendValue = 0f;
|
private float currentBlendValue = 0f;
|
||||||
|
|
||||||
private float baseColliderZ;
|
private float baseColliderZ;
|
||||||
|
|
||||||
private float Max = 0f;
|
private float Max = 0f;
|
||||||
private float Min = 0f;
|
private float Min = 0f;
|
||||||
|
|
||||||
public BoxCollider hookCollider; //钩子的碰撞
|
public BoxCollider hookCollider; //钩子的碰撞
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
}
|
}
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
Max = -(2.49513f - 0.5113189f) / 100;
|
Max = -(2.49513f - 0.5113189f) / 100;
|
||||||
Min = (6.295807f - 0.3099952f) / 100;
|
Min = (6.295807f - 0.3099952f) / 100;
|
||||||
}
|
}
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
HandleBridgeMovement();
|
HandleBridgeMovement();
|
||||||
HandleHookMovement();
|
HandleHookMovement();
|
||||||
HandleHookLift();
|
HandleHookLift();
|
||||||
hookSize();
|
hookSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleBridgeMovement()
|
void HandleBridgeMovement()
|
||||||
{
|
{
|
||||||
// I/K 控制横杆前后
|
// I/K 控制横杆前后
|
||||||
float input = 0;
|
float input = 0;
|
||||||
if (Input.GetKey(KeyCode.I))
|
if (Input.GetKey(KeyCode.I))
|
||||||
input = 1;
|
input = 1;
|
||||||
else if (Input.GetKey(KeyCode.K))
|
else if (Input.GetKey(KeyCode.K))
|
||||||
input = -1;
|
input = -1;
|
||||||
Vector3 newPos = bridge.position + Vector3.forward * input * bridgeSpeed * Time.deltaTime;
|
Vector3 newPos = bridge.position + Vector3.forward * input * bridgeSpeed * Time.deltaTime;
|
||||||
newPos.z = Mathf.Clamp(newPos.z, bridgeMinZ, bridgeMaxZ);
|
newPos.z = Mathf.Clamp(newPos.z, bridgeMinZ, bridgeMaxZ);
|
||||||
bridge.position = newPos;
|
bridge.position = newPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleHookMovement()
|
void HandleHookMovement()
|
||||||
{
|
{
|
||||||
// J/L 控制滑轮前后
|
// J/L 控制滑轮前后
|
||||||
float input = 0;
|
float input = 0;
|
||||||
if (Input.GetKey(KeyCode.J))
|
if (Input.GetKey(KeyCode.J))
|
||||||
input = 1;
|
input = 1;
|
||||||
else if (Input.GetKey(KeyCode.L))
|
else if (Input.GetKey(KeyCode.L))
|
||||||
input = -1;
|
input = -1;
|
||||||
Vector3 newPos = hook.position + Vector3.left * input * hookSpeed * Time.deltaTime;
|
Vector3 newPos = hook.position + Vector3.left * input * hookSpeed * Time.deltaTime;
|
||||||
newPos.x = Mathf.Clamp(newPos.x, hookMinZ, hookMaxZ);
|
newPos.x = Mathf.Clamp(newPos.x, hookMinZ, hookMaxZ);
|
||||||
hook.position = newPos;
|
hook.position = newPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleHookLift()
|
void HandleHookLift()
|
||||||
{
|
{
|
||||||
if (hookRenderer == null)
|
if (hookRenderer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float input = 0;
|
float input = 0;
|
||||||
if (Input.GetKey(KeyCode.U))
|
if (Input.GetKey(KeyCode.U))
|
||||||
input = 1; // 上升
|
input = 1; // 上升
|
||||||
else if (Input.GetKey(KeyCode.O))
|
else if (Input.GetKey(KeyCode.O))
|
||||||
input = -1; // 下降
|
input = -1; // 下降
|
||||||
|
|
||||||
currentBlendValue += input * blendShapeSpeed * Time.deltaTime;
|
currentBlendValue += input * blendShapeSpeed * Time.deltaTime;
|
||||||
currentBlendValue = Mathf.Clamp(currentBlendValue, minBlendShapeValue, maxBlendShapeValue);
|
currentBlendValue = Mathf.Clamp(currentBlendValue, minBlendShapeValue, maxBlendShapeValue);
|
||||||
|
|
||||||
hookRenderer.SetBlendShapeWeight(hookBlendShapeIndex, currentBlendValue);
|
hookRenderer.SetBlendShapeWeight(hookBlendShapeIndex, currentBlendValue);
|
||||||
}
|
}
|
||||||
public void hookSize()
|
public void hookSize()
|
||||||
{
|
{
|
||||||
if (hookCollider != null)
|
if (hookCollider != null)
|
||||||
{
|
{
|
||||||
hookCollider.center = new Vector3(-0.1262663f, -0.01883008f, -0.5113189f + currentBlendValue * Max);
|
hookCollider.center = new Vector3(-0.1262663f, -0.01883008f, -0.5113189f + currentBlendValue * Max);
|
||||||
hookCollider.size = new Vector3(0.1096101f, 0.2627291f, 0.3099952f + currentBlendValue *Min);
|
hookCollider.size = new Vector3(0.1096101f, 0.2627291f, 0.3099952f + currentBlendValue * Min);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue