From d1de5e6481b5f6af986b364375a344729a0c39e7 Mon Sep 17 00:00:00 2001 From: Tore Bergebakken Date: Fri, 10 Jan 2025 20:58:40 +0100 Subject: [PATCH] Increase speed of conveyor belt at endpoints --- Assets/Scenes/GrandCanyon.unity | 44 ++++++++++++++++++++ Assets/Scripts/Interactables/ConveyorBelt.cs | 11 ++--- 2 files changed, 48 insertions(+), 7 deletions(-) diff --git a/Assets/Scenes/GrandCanyon.unity b/Assets/Scenes/GrandCanyon.unity index 1f08dab6..775db9f9 100644 --- a/Assets/Scenes/GrandCanyon.unity +++ b/Assets/Scenes/GrandCanyon.unity @@ -1260,6 +1260,10 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 2110608845} m_Modifications: + - target: {fileID: 728497790455784594, guid: 5c2a4211bc1ea974889527b14087519c, type: 3} + propertyPath: force + value: 35 + objectReference: {fileID: 0} - target: {fileID: 4772641596302512589, guid: 5c2a4211bc1ea974889527b14087519c, type: 3} propertyPath: m_Name value: SmallConveyorBelt (30) @@ -1610,6 +1614,10 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 553747994} m_Modifications: + - target: {fileID: 728497790455784594, guid: 5c2a4211bc1ea974889527b14087519c, type: 3} + propertyPath: force + value: 45 + objectReference: {fileID: 0} - target: {fileID: 4772641596302512589, guid: 5c2a4211bc1ea974889527b14087519c, type: 3} propertyPath: m_Name value: SmallConveyorBelt (6) @@ -3265,6 +3273,10 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 2110608845} m_Modifications: + - target: {fileID: 728497790455784594, guid: 5c2a4211bc1ea974889527b14087519c, type: 3} + propertyPath: force + value: 40 + objectReference: {fileID: 0} - target: {fileID: 4772641596302512589, guid: 5c2a4211bc1ea974889527b14087519c, type: 3} propertyPath: m_Name value: SmallConveyorBelt (31) @@ -4153,6 +4165,10 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 553747994} m_Modifications: + - target: {fileID: 728497790455784594, guid: 5c2a4211bc1ea974889527b14087519c, type: 3} + propertyPath: force + value: 80 + objectReference: {fileID: 0} - target: {fileID: 4772641596302512589, guid: 5c2a4211bc1ea974889527b14087519c, type: 3} propertyPath: m_Name value: SmallConveyorBelt (18) @@ -5128,6 +5144,10 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 553747994} m_Modifications: + - target: {fileID: 728497790455784594, guid: 5c2a4211bc1ea974889527b14087519c, type: 3} + propertyPath: force + value: 40 + objectReference: {fileID: 0} - target: {fileID: 4772641596302512589, guid: 5c2a4211bc1ea974889527b14087519c, type: 3} propertyPath: m_Name value: SmallConveyorBelt (5) @@ -5347,6 +5367,10 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 2110608845} m_Modifications: + - target: {fileID: 728497790455784594, guid: 5c2a4211bc1ea974889527b14087519c, type: 3} + propertyPath: force + value: 60 + objectReference: {fileID: 0} - target: {fileID: 4772641596302512589, guid: 5c2a4211bc1ea974889527b14087519c, type: 3} propertyPath: m_Name value: SmallConveyorBelt (33) @@ -6772,6 +6796,10 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 553747994} m_Modifications: + - target: {fileID: 728497790455784594, guid: 5c2a4211bc1ea974889527b14087519c, type: 3} + propertyPath: force + value: 55 + objectReference: {fileID: 0} - target: {fileID: 4772641596302512589, guid: 5c2a4211bc1ea974889527b14087519c, type: 3} propertyPath: m_Name value: SmallConveyorBelt (16) @@ -7232,6 +7260,10 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 553747994} m_Modifications: + - target: {fileID: 728497790455784594, guid: 5c2a4211bc1ea974889527b14087519c, type: 3} + propertyPath: force + value: 65 + objectReference: {fileID: 0} - target: {fileID: 4772641596302512589, guid: 5c2a4211bc1ea974889527b14087519c, type: 3} propertyPath: m_Name value: SmallConveyorBelt (17) @@ -7869,6 +7901,10 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 2110608845} m_Modifications: + - target: {fileID: 728497790455784594, guid: 5c2a4211bc1ea974889527b14087519c, type: 3} + propertyPath: force + value: 50 + objectReference: {fileID: 0} - target: {fileID: 4772641596302512589, guid: 5c2a4211bc1ea974889527b14087519c, type: 3} propertyPath: m_Name value: SmallConveyorBelt (32) @@ -9119,6 +9155,10 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 553747994} m_Modifications: + - target: {fileID: 728497790455784594, guid: 5c2a4211bc1ea974889527b14087519c, type: 3} + propertyPath: force + value: 50 + objectReference: {fileID: 0} - target: {fileID: 4772641596302512589, guid: 5c2a4211bc1ea974889527b14087519c, type: 3} propertyPath: m_Name value: SmallConveyorBelt (7) @@ -11042,6 +11082,10 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 553747994} m_Modifications: + - target: {fileID: 728497790455784594, guid: 5c2a4211bc1ea974889527b14087519c, type: 3} + propertyPath: force + value: 35 + objectReference: {fileID: 0} - target: {fileID: 4772641596302512589, guid: 5c2a4211bc1ea974889527b14087519c, type: 3} propertyPath: m_Name value: SmallConveyorBelt diff --git a/Assets/Scripts/Interactables/ConveyorBelt.cs b/Assets/Scripts/Interactables/ConveyorBelt.cs index da6a5945..2cc40304 100644 --- a/Assets/Scripts/Interactables/ConveyorBelt.cs +++ b/Assets/Scripts/Interactables/ConveyorBelt.cs @@ -9,11 +9,8 @@ public class ConveyorBelt : MonoBehaviour [SerializeField] private Vector3 direction = Vector3.forward; - [SerializeField] - private float visualSpeed = 1; - - [SerializeField] - private float visualRotationSpeed = 1; + private const float visualSpeedFactor = 4f / 30f; + private const float visualRotationSpeedFactor = 200f / 30f; [SerializeField] private Renderer beltMesh; @@ -49,14 +46,14 @@ private void Update() // TODO more flexible than just z var multiplier = direction.z * ConveyorBeltDirector.DirectionMultiplier; material.SetFloat("_Direction", multiplier); - offset += Time.deltaTime * visualSpeed * multiplier; + offset += Time.deltaTime * visualSpeedFactor * force * multiplier; offset = offset.Mod(1); material.SetFloat("_Offset", offset); // Rotate wheeels foreach (var wheel in wheels) { - var delta = Time.deltaTime * visualRotationSpeed * multiplier; + var delta = Time.deltaTime * visualRotationSpeedFactor * force * multiplier; wheel.Rotate(new Vector3(delta, 0, 0)); } }