From 41373270b5d0d1105e8e692e23cbaf214a91aadf Mon Sep 17 00:00:00 2001 From: Leushina Date: Thu, 25 Jun 2026 13:02:44 +0300 Subject: [PATCH] fix some robotics scripts --- Assets/CustomLibs/unity_robotics | 2 +- Assets/Scenes/main.unity | 54 ++++++++++++++------------ Assets/Scripts/ResetPosition.cs | 57 ---------------------------- Assets/Scripts/ResetPosition.cs.meta | 2 - 4 files changed, 30 insertions(+), 85 deletions(-) delete mode 100644 Assets/Scripts/ResetPosition.cs delete mode 100644 Assets/Scripts/ResetPosition.cs.meta diff --git a/Assets/CustomLibs/unity_robotics b/Assets/CustomLibs/unity_robotics index 3163d78..d2d59f8 160000 --- a/Assets/CustomLibs/unity_robotics +++ b/Assets/CustomLibs/unity_robotics @@ -1 +1 @@ -Subproject commit 3163d782ca8788cae899a3ca280d9806e6de701b +Subproject commit d2d59f891fa3d1c39299464dc165b2427a9b8995 diff --git a/Assets/Scenes/main.unity b/Assets/Scenes/main.unity index ef030b6..deb15b4 100644 --- a/Assets/Scenes/main.unity +++ b/Assets/Scenes/main.unity @@ -8560,9 +8560,9 @@ ArticulationBody: target: 0 targetVelocity: 0 driveType: 0 - m_LinearDamping: 0.05 - m_AngularDamping: 0.05 - m_JointFriction: 0.05 + m_LinearDamping: 0 + m_AngularDamping: 0 + m_JointFriction: 0 m_CenterOfMass: {x: 0, y: 0, z: 0} m_InertiaTensor: {x: 1, y: 1, z: 1} m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1} @@ -86722,7 +86722,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 792546717} - - component: {fileID: 792546718} + - component: {fileID: 792546719} m_Layer: 0 m_Name: sirius_bot m_TagString: UtilityObj @@ -86745,7 +86745,7 @@ Transform: m_Children: [] m_Father: {fileID: 357998453} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &792546718 +--- !u!114 &792546719 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -86754,19 +86754,23 @@ MonoBehaviour: m_GameObject: {fileID: 792546716} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 46757fd7e9d69626c8827a94cbb3965a, type: 3} + m_Script: {fileID: 11500000, guid: 713fd61d8164fc73596a3b02b4cde489, type: 3} m_Name: m_EditorClassIdentifier: - front_left_wheel: {fileID: 1349958476} - front_right_wheel: {fileID: 2082835350} - back_left_wheel: {fileID: 1160352884} - back_right_wheel: {fileID: 814849843} - maxLinearSpeed: 3 - maxRotationalSpeed: 2 - wheelRadius: 0.22 - trackWidth: 0.47 + _wheelList: + - name: front_left_wheel + obj: {fileID: 1349958476} + - name: front_right_wheel + obj: {fileID: 2082835350} + - name: back_left_wheel + obj: {fileID: 1160352884} + - name: back_right_wheel + obj: {fileID: 814849843} + _robotBody: {fileID: 915175386} + maxLinearSpeed: 10 + maxAngularSpeed: 2 _frequency: 1 - use_namespace: 0 + useNamespace: 1 --- !u!1001 &794370220 PrefabInstance: m_ObjectHideFlags: 0 @@ -89411,7 +89415,7 @@ ArticulationBody: m_GameObject: {fileID: 814849839} m_Enabled: 1 serializedVersion: 6 - m_Mass: 5 + m_Mass: 3 m_ParentAnchorPosition: {x: 0.27999878, y: -0.13500002, z: -0.3} m_ParentAnchorRotation: {x: 0, y: 0, z: 0, w: 1} m_AnchorPosition: {x: 0, y: 0, z: 0} @@ -100888,7 +100892,7 @@ ArticulationBody: m_GameObject: {fileID: 915175385} m_Enabled: 1 serializedVersion: 6 - m_Mass: 10 + m_Mass: 1 m_ParentAnchorPosition: {x: 0, y: 0, z: 0} m_ParentAnchorRotation: {x: 0, y: 0, z: 0.7071068, w: 0.7071068} m_AnchorPosition: {x: 0, y: 0, z: 0} @@ -100928,8 +100932,8 @@ ArticulationBody: target: 0 targetVelocity: 0 driveType: 0 - m_LinearDamping: 0.05 - m_AngularDamping: 0.05 + m_LinearDamping: 0 + m_AngularDamping: 0 m_JointFriction: 0.05 m_CenterOfMass: {x: -0, y: 0, z: 0} m_InertiaTensor: {x: 0.56666666, y: 0.78, z: 0.37466666} @@ -128824,7 +128828,7 @@ ArticulationBody: m_GameObject: {fileID: 1160352880} m_Enabled: 1 serializedVersion: 6 - m_Mass: 5 + m_Mass: 3 m_ParentAnchorPosition: {x: -0.27999878, y: -0.13500002, z: -0.3} m_ParentAnchorRotation: {x: 0, y: 0, z: 0, w: 1} m_AnchorPosition: {x: 0, y: 0, z: 0} @@ -149749,7 +149753,7 @@ ArticulationBody: m_GameObject: {fileID: 1349958472} m_Enabled: 1 serializedVersion: 6 - m_Mass: 5 + m_Mass: 3 m_ParentAnchorPosition: {x: -0.27999878, y: -0.13500002, z: 0.3} m_ParentAnchorRotation: {x: 0, y: 0, z: 0, w: 1} m_AnchorPosition: {x: 0, y: 0, z: 0} @@ -180431,9 +180435,9 @@ ArticulationBody: target: 0 targetVelocity: 0 driveType: 0 - m_LinearDamping: 0.05 - m_AngularDamping: 0.05 - m_JointFriction: 0.05 + m_LinearDamping: 0 + m_AngularDamping: 0 + m_JointFriction: 0 m_CenterOfMass: {x: 0, y: 0, z: 0} m_InertiaTensor: {x: 1, y: 1, z: 1} m_InertiaRotation: {x: 0, y: 0, z: 0, w: 1} @@ -227282,7 +227286,7 @@ ArticulationBody: m_GameObject: {fileID: 2082835346} m_Enabled: 1 serializedVersion: 6 - m_Mass: 5 + m_Mass: 3 m_ParentAnchorPosition: {x: 0.27999878, y: -0.13500002, z: 0.3} m_ParentAnchorRotation: {x: 0, y: 0, z: 0, w: 1} m_AnchorPosition: {x: 0, y: 0, z: 0} diff --git a/Assets/Scripts/ResetPosition.cs b/Assets/Scripts/ResetPosition.cs deleted file mode 100644 index 3b39aba..0000000 --- a/Assets/Scripts/ResetPosition.cs +++ /dev/null @@ -1,57 +0,0 @@ -using UnityEngine; - -public class ResetPosition : MonoBehaviour -{ - [SerializeField] private Terrain currentTerrain; - [SerializeField] private LayerMask _terrainLayer = 1 << 0; - [SerializeField] private float _groundOffset = 1.0f; // m, shift during raycast to stick robot to the ground - - public bool startRotation = false; - private Vector3 targetEuler, targetPosition; - private Quaternion targetRotation; - private Vector3 terrainPosition, terrainNormal; - private float normalizedX, normalizedZ; - private Vector3 faceDirection; - - private ArticulationBody body; - // draw ray and spawn object little up - // Start is called once before the first execution of Update after the MonoBehaviour is created - - void Start() - { - body = GetComponent(); - } - - void FixedUpdate() { - if (startRotation) - { - FixPosition(); - } - } - - void FixPosition() - { - terrainPosition = transform.position - currentTerrain.transform.position; - normalizedX = Mathf.InverseLerp(0, currentTerrain.terrainData.size.x, terrainPosition.x); - normalizedX = Mathf.Clamp01(normalizedX); - normalizedZ = Mathf.InverseLerp(0, currentTerrain.terrainData.size.z, terrainPosition.z); - normalizedZ = Mathf.Clamp01(normalizedZ); - terrainNormal = currentTerrain.terrainData.GetInterpolatedNormal(normalizedX, normalizedZ); - - faceDirection = Vector3.Cross(terrainNormal, -transform.right); - - Quaternion predictedRot = Quaternion.LookRotation(faceDirection, terrainNormal); - targetEuler = predictedRot.eulerAngles; - targetEuler.y = transform.rotation.eulerAngles.y; - - targetRotation = Quaternion.Euler(targetEuler); - targetPosition = new Vector3( - transform.position.x, - transform.position.y + _groundOffset, - transform.position.z); - - body.TeleportRoot(targetPosition, targetRotation); - - startRotation = false; - } -} diff --git a/Assets/Scripts/ResetPosition.cs.meta b/Assets/Scripts/ResetPosition.cs.meta deleted file mode 100644 index 3446abf..0000000 --- a/Assets/Scripts/ResetPosition.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 4b9c4dfebd00ecd8aaf8dbf69d9248e2 \ No newline at end of file