From 69e793c9103548ae83812c05159e31a6daa56778 Mon Sep 17 00:00:00 2001 From: MelekTaus Moribundus Date: Wed, 24 Jun 2026 21:50:26 +0200 Subject: [PATCH] Auto-deactivate pipette after pick and remap wall-climb rotation to RMB Reset the pipette toggle after a successful pick so each pick is a one-shot action (HUD toggle follows via the Picked sync). Split the wall-climb pose drag so the lean-out offset stays on LMB while body rotation moves to RMB, letting both be held independently. Also pulls in the terrain physics module and the user's scene setup for the terrain test area. Co-Authored-By: Claude Opus 4.8 --- Assets/Scenes/SampleScene.unity | 16 ++++---- Assets/Scripts/MeshPainter.Pick.cs | 3 ++ Assets/Scripts/PlayerCharacterController.cs | 41 ++++++++++++++------- Packages/manifest.json | 1 + Packages/packages-lock.json | 11 +++++- 5 files changed, 50 insertions(+), 22 deletions(-) diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index a9a7342..afc8c3c 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -714,8 +714,8 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 172071430} serializedVersion: 2 - m_LocalRotation: {x: 0.1305262, y: -2.9837799e-12, z: 3.8899596e-13, w: 0.9914449} - m_LocalPosition: {x: 0, y: 1.9146858, z: -4.3466663} + m_LocalRotation: {x: 0.1305262, y: -3.7968678e-12, z: 4.3538282e-13, w: 0.9914449} + m_LocalPosition: {x: 33.03, y: 9.514687, z: 29.493334} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -1078,8 +1078,8 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 330585543} serializedVersion: 2 - m_LocalRotation: {x: 0.1305262, y: -2.9842923e-12, z: 3.928896e-13, w: 0.9914449} - m_LocalPosition: {x: 0, y: 1.9146858, z: -4.3466663} + m_LocalRotation: {x: 0.1305262, y: -3.8055076e-12, z: 5.010046e-13, w: 0.9914449} + m_LocalPosition: {x: 33.03, y: 9.514687, z: 29.493334} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -1178,7 +1178,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!108 &410087040 Light: m_ObjectHideFlags: 0 @@ -1586,7 +1586,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 2147483647 - m_IsActive: 1 + m_IsActive: 0 --- !u!4 &686187287 Transform: m_ObjectHideFlags: 0 @@ -2011,7 +2011,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!114 &832575518 MonoBehaviour: m_ObjectHideFlags: 0 @@ -2538,7 +2538,7 @@ Transform: m_GameObject: {fileID: 1141039638} serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalPosition: {x: 33.03, y: 7.6, z: 33.84} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: diff --git a/Assets/Scripts/MeshPainter.Pick.cs b/Assets/Scripts/MeshPainter.Pick.cs index a0f5499..3105a00 100644 --- a/Assets/Scripts/MeshPainter.Pick.cs +++ b/Assets/Scripts/MeshPainter.Pick.cs @@ -58,6 +58,9 @@ public partial class MeshPainter paintOcclusion = true; paintEmission = true; + // A pick is a one-shot action: leave pipette mode automatically so the next click paints. + pipette = false; + // Let listeners (the in-game HUD) refresh their widgets to the adopted values + flags. Picked?.Invoke(); } diff --git a/Assets/Scripts/PlayerCharacterController.cs b/Assets/Scripts/PlayerCharacterController.cs index b70126f..07d1799 100644 --- a/Assets/Scripts/PlayerCharacterController.cs +++ b/Assets/Scripts/PlayerCharacterController.cs @@ -9,9 +9,10 @@ using UnityEngine.InputSystem; /// /// Wall-climb (entered by pushing the move input into a wall): W/S climb straight up/down the /// wall at a constant speed, A/D strafe left/right relative to the camera, and the body always -/// faces the wall. Holding the left mouse button and dragging sets the wall pose (vertical = lean -/// out from / back to the wall, horizontal = turn the body) and pauses the camera orbit; the -/// lean-out offset eases back to zero while moving, the turn is held until leaving the wall. +/// faces the wall. Holding the left mouse button and dragging up/down leans out from / back to +/// the wall; holding the right mouse button and dragging left/right turns the body. Either pauses +/// the camera orbit; the lean-out offset eases back to zero while moving, the turn is held until +/// leaving the wall. /// On leaving, the body eases back to its movement direction. Jumping detaches and works /// normally; re-grab is blocked while rising and resumes once falling and pushing into a wall. /// Reaching the top edge mantles the character over onto the surface. @@ -371,9 +372,9 @@ public class PlayerCharacterController : MonoBehaviour /// /// Movement while climbing, for both walls and ceilings (distinguished by the surface /// normal). On a WALL: W/S climb straight up/down at a constant speed (camera pitch never - /// tilts them), A/D strafe left/right relative to the camera, the body faces the wall, and - /// holding the left mouse button drags the wall pose (vertical = lean out via - /// , horizontal = body yaw via ). On a + /// tilts them), A/D strafe left/right relative to the camera, the body faces the wall, the + /// left mouse button + vertical drag leans out via , and the right + /// mouse button + horizontal drag turns the body via . On a /// CEILING: the body stays upright and moves WASD camera-relative in the horizontal plane /// (like on the ground), facing the move direction; the lean-out drag pulls down off the /// ceiling. Surface normal and gap are re-measured each frame; reaching a wall's top edge @@ -476,17 +477,22 @@ public class PlayerCharacterController : MonoBehaviour } } - // Left button + drag adjusts the pose: vertical = lean-out offset (mouse down = away - // from the surface; down off a ceiling), horizontal = body yaw (wall only). The offset - // eases back to zero while moving and never detaches. Dragging pauses the camera orbit. - if (found && IsLeftMouseHeld()) + // Left button + vertical drag sets the lean-out offset (mouse down = away from the + // surface; down off a ceiling); right button + horizontal drag turns the body (wall + // only). The offset eases back to zero while moving and never detaches, the turn is + // held until leaving the wall. Either drag pauses the camera orbit. + bool offsetDrag = found && IsLeftMouseHeld(); + bool yawDrag = found && IsRightMouseHeld(); + if (offsetDrag || yawDrag) { _offsetDragging = true; Vector2 drag = ReadMouseDelta(); - _wallOffset = Mathf.Clamp(_wallOffset - drag.y * wallOffsetSensitivity, 0f, wallMaxOffset); - _wallYaw += drag.x * wallRotateSensitivity; + if (offsetDrag) + _wallOffset = Mathf.Clamp(_wallOffset - drag.y * wallOffsetSensitivity, 0f, wallMaxOffset); + if (yawDrag) + _wallYaw += drag.x * wallRotateSensitivity; } - else if (hasMoveInput) + if (!offsetDrag && hasMoveInput) { _wallOffset = Mathf.MoveTowards(_wallOffset, 0f, wallOffsetReturnSpeed * dt); } @@ -771,6 +777,15 @@ public class PlayerCharacterController : MonoBehaviour #endif } + bool IsRightMouseHeld() + { +#if ENABLE_INPUT_SYSTEM + return Mouse.current != null && Mouse.current.rightButton.isPressed; +#else + return Input.GetMouseButton(1); +#endif + } + Vector2 ReadMouseDelta() { #if ENABLE_INPUT_SYSTEM diff --git a/Packages/manifest.json b/Packages/manifest.json index 06b812b..9d05b00 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -20,6 +20,7 @@ "com.unity.modules.particlesystem": "1.0.0", "com.unity.modules.physics": "1.0.0", "com.unity.modules.screencapture": "1.0.0", + "com.unity.modules.terrainphysics": "1.0.0", "com.unity.modules.ui": "1.0.0", "com.unity.modules.uielements": "1.0.0", "com.unity.modules.umbra": "1.0.0", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 19963e3..5d92fcd 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -315,10 +315,19 @@ }, "com.unity.modules.terrain": { "version": "1.0.0", - "depth": 2, + "depth": 1, "source": "builtin", "dependencies": {} }, + "com.unity.modules.terrainphysics": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.terrain": "1.0.0" + } + }, "com.unity.modules.ui": { "version": "1.0.0", "depth": 0,