From 179a4bcfe0be9a589d293756f3911069e3e787a6 Mon Sep 17 00:00:00 2001 From: Pasha Date: Thu, 15 Jan 2026 18:49:00 +0000 Subject: [PATCH] Made player "move" --- Assets/Scenes/WorldScene.unity | 135 ++++++++++++++++++++++- Assets/Scripts/World/PlayerController.cs | 17 +++ 2 files changed, 151 insertions(+), 1 deletion(-) diff --git a/Assets/Scenes/WorldScene.unity b/Assets/Scenes/WorldScene.unity index 4567bae..54e10ac 100644 --- a/Assets/Scenes/WorldScene.unity +++ b/Assets/Scenes/WorldScene.unity @@ -592,6 +592,68 @@ MonoBehaviour: m_LightCookieSize: {x: 1, y: 1} m_LightCookieOffset: {x: 0, y: 0} m_SoftShadowQuality: 0 +--- !u!1 &832169853 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 832169854} + m_Layer: 0 + m_Name: LerpPosition2 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &832169854 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 832169853} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -3, y: 1.5, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &988211805 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 988211806} + m_Layer: 0 + m_Name: LerpPosition3 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &988211806 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 988211805} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 3, y: 1.5, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1069879340 GameObject: m_ObjectHideFlags: 0 @@ -698,6 +760,68 @@ MeshFilter: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1069879340} m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} +--- !u!1 &1120251455 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1120251456} + m_Layer: 0 + m_Name: LerpPosition1 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1120251456 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1120251455} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -3, y: 1.5, z: -8} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1176743696 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1176743697} + m_Layer: 0 + m_Name: LerpPosition4 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1176743697 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1176743696} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 3, y: 1.5, z: 8} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &1184458447 PrefabInstance: m_ObjectHideFlags: 0 @@ -876,7 +1000,7 @@ Camera: y: 0 width: 1 height: 1 - near clip plane: 0.3 + near clip plane: 0.01 far clip plane: 1000 field of view: 60 orthographic: 0 @@ -967,6 +1091,11 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 42603e4f95b24efa85355a04450c20e2, type: 3} m_Name: m_EditorClassIdentifier: + LerpPositions: + - {fileID: 1120251456} + - {fileID: 832169854} + - {fileID: 988211806} + - {fileID: 1176743697} --- !u!23 &1211206071 stripped MeshRenderer: m_CorrespondingSourceObject: {fileID: 2963162269859711420, guid: 35a37f1ca60417a4393dc48a27c21574, @@ -1557,3 +1686,7 @@ SceneRoots: - {fileID: 783130826} - {fileID: 1184458447} - {fileID: 1904568118} + - {fileID: 1120251456} + - {fileID: 832169854} + - {fileID: 988211806} + - {fileID: 1176743697} diff --git a/Assets/Scripts/World/PlayerController.cs b/Assets/Scripts/World/PlayerController.cs index b4b28ae..4576139 100644 --- a/Assets/Scripts/World/PlayerController.cs +++ b/Assets/Scripts/World/PlayerController.cs @@ -1,14 +1,31 @@ using UnityEngine; +using UnityEngine.Serialization; namespace InterfaceOff.WorldScene { public class PlayerController : MonoBehaviour { private static PlayerController Instance; + + [field: SerializeField] private Transform[] LerpPositions; + private float LerpValue; public static void SetPos(Vector3 pos) { Instance.transform.position = pos; } + + private void Update() + { + LerpValue = (LerpValue + Time.deltaTime) % 3f; + + int section = Mathf.FloorToInt(LerpValue); + float sectionLerp = LerpValue % 1f; + + Vector3 a = LerpPositions[section + 0].position; + Vector3 b = LerpPositions[section + 1].position; + + transform.position = Vector3.Lerp(a, b, sectionLerp); + } } } \ No newline at end of file