Add Cinemachine third-person orbit camera and fix paint raycast

- Install Cinemachine 3.1.7 and set up an orbital third-person camera rig
  (CinemachineBrain, OrbitalFollow, RotationComposer, Deoccluder).
- Add ThirdPersonOrbitInput: mouse-driven orbit and wheel zoom with a Tab
  toggle that unlocks the cursor and pauses rotation.
- Fix MeshPainter so the paint ray skips the player's CharacterController
  capsule (and any other collider) and always targets the mesh collider,
  so painting works from every camera angle.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 4.8 committed 2026-06-22 14:31:45 +02:00
1 parent 792c8c964f
commit 6e8ab4bc6d
6 files changed
+545 -10

No files matched your search

+306 -8
View File
@@ -119,6 +119,238 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &172071430
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 172071436}
- component: {fileID: 172071435}
- component: {fileID: 172071434}
- component: {fileID: 172071433}
- component: {fileID: 172071432}
- component: {fileID: 172071431}
m_Layer: 0
m_Name: ThirdPersonCamera
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &172071431
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 172071430}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: df129be8fadab79498bd429a59bb98e4, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::ThirdPersonOrbitInput
horizontalSensitivity: 0.2
verticalSensitivity: 0.15
invertY: 0
toggleKey: 3
startInLookMode: 1
enableZoom: 1
zoomSpeed: 0.5
minRadius: 1.5
maxRadius: 8
lockCursorInLookMode: 1
--- !u!114 &172071432
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 172071430}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dbe43d662878a7c43bcd44d43c9e2094, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.Cinemachine::Unity.Cinemachine.CinemachineDeoccluder
CollideAgainst:
serializedVersion: 2
m_Bits: 1
IgnoreTag: Player
TransparentLayers:
serializedVersion: 2
m_Bits: 0
MinimumDistanceFromTarget: 0.5
AvoidObstacles:
Enabled: 1
DistanceLimit: 0
MinimumOcclusionTime: 0
CameraRadius: 0.2
UseFollowTarget:
Enabled: 0
YOffset: 0
Strategy: 0
MaximumEffort: 4
SmoothingTime: 0
Damping: 0.2
DampingWhenOccluded: 0
ShotQualityEvaluation:
Enabled: 0
OptimalDistance: 10
NearLimit: 5
FarLimit: 30
MaxQualityBoost: 0.2
--- !u!114 &172071433
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 172071430}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f38bda98361e1de48a4ca2bd86ea3c17, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.Cinemachine::Unity.Cinemachine.CinemachineRotationComposer
Composition:
ScreenPosition: {x: 0, y: 0}
DeadZone:
Enabled: 0
Size: {x: 0.2, y: 0.2}
HardLimits:
Enabled: 0
Size: {x: 0.8, y: 0.8}
Offset: {x: 0, y: 0}
CenterOnActivate: 1
TargetOffset: {x: 0, y: 0, z: 0}
Damping: {x: 0.5, y: 0.5}
Lookahead:
Enabled: 0
Time: 0
Smoothing: 0
IgnoreY: 0
--- !u!114 &172071434
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 172071430}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3b5d7c088409d9a40b7b09aa707777f8, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.Cinemachine::Unity.Cinemachine.CinemachineOrbitalFollow
TargetOffset: {x: 0, y: 0, z: 0}
TrackerSettings:
BindingMode: 4
PositionDamping: {x: 1, y: 1, z: 1}
AngularDampingMode: 0
RotationDamping: {x: 1, y: 1, z: 1}
QuaternionDamping: 1
OrbitStyle: 0
Radius: 4.5
Orbits:
Top:
Radius: 2
Height: 5
Center:
Radius: 4
Height: 2.25
Bottom:
Radius: 2.5
Height: 0.1
SplineCurvature: 0.5
RecenteringTarget: 2
HorizontalAxis:
Value: 0
Center: 0
Range: {x: -180, y: 180}
Wrap: 1
Recentering:
Enabled: 0
Wait: 1
Time: 2
Restrictions: 0
VerticalAxis:
Value: 15
Center: 12
Range: {x: -20, y: 60}
Wrap: 0
Recentering:
Enabled: 0
Wait: 1
Time: 2
Restrictions: 0
RadialAxis:
Value: 1
Center: 1
Range: {x: 1, y: 1}
Wrap: 0
Recentering:
Enabled: 0
Wait: 1
Time: 2
Restrictions: 0
--- !u!114 &172071435
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 172071430}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f9dfa5b682dcd46bda6128250e975f58, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.Cinemachine::Unity.Cinemachine.CinemachineCamera
Priority:
Enabled: 0
m_Value: 0
OutputChannel: 1
StandbyUpdate: 2
m_StreamingVersion: 20241001
m_LegacyPriority: 0
Target:
TrackingTarget: {fileID: 1774267802}
LookAtTarget: {fileID: 1774267802}
CustomLookAtTarget: 0
Lens:
FieldOfView: 40
OrthographicSize: 10
NearClipPlane: 0.1
FarClipPlane: 5000
Dutch: 0
ModeOverride: 0
PhysicalProperties:
GateFit: 2
SensorSize: {x: 21.946, y: 16.002}
LensShift: {x: 0, y: 0}
FocusDistance: 10
Iso: 200
ShutterSpeed: 0.005
Aperture: 16
BladeCount: 5
Curvature: {x: 2, y: 11}
BarrelClipping: 0.25
Anamorphism: 0
BlendHint: 0
--- !u!4 &172071436
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 172071430}
serializedVersion: 2
m_LocalRotation: {x: 0.1305262, y: 0.00000002667958, z: -0.0000000035124335, w: 0.9914449}
m_LocalPosition: {x: 0, y: 3.1646857, z: -4.3466663}
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 &200502118
GameObject:
m_ObjectHideFlags: 0
@@ -243,6 +475,7 @@ GameObject:
- component: {fileID: 330585545}
- component: {fileID: 330585544}
- component: {fileID: 330585547}
- component: {fileID: 330585548}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
@@ -289,11 +522,11 @@ Camera:
y: 0
width: 1
height: 1
near clip plane: 0.3
far clip plane: 1000
field of view: 60
near clip plane: 0.1
far clip plane: 5000
field of view: 40
orthographic: 0
orthographic size: 5
orthographic size: 10
m_Depth: -1
m_CullingMask:
serializedVersion: 2
@@ -317,8 +550,8 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 330585543}
serializedVersion: 2
m_LocalRotation: {x: 0.3420201, y: 0, z: 0, w: 0.9396927}
m_LocalPosition: {x: 0, y: 4.43, z: -7.8}
m_LocalRotation: {x: 0.1305262, y: 0, z: 0, w: 0.9914449}
m_LocalPosition: {x: 0, y: 3.1646857, z: -4.3466663}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
@@ -368,6 +601,38 @@ MonoBehaviour:
m_VarianceClampScale: 0.9
m_ContrastAdaptiveSharpening: 0
m_Version: 2
--- !u!114 &330585548
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 330585543}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 72ece51f2901e7445ab60da3685d6b5f, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.Cinemachine::Unity.Cinemachine.CinemachineBrain
ShowDebugText: 0
ShowCameraFrustum: 1
IgnoreTimeScale: 0
WorldUpOverride: {fileID: 0}
ChannelMask: -1
UpdateMethod: 2
BlendUpdateMethod: 1
LensModeOverride:
Enabled: 0
DefaultMode: 2
DefaultBlend:
Style: 1
Time: 2
CustomCurve:
serializedVersion: 2
m_Curve: []
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
CustomBlends: {fileID: 0}
--- !u!1 &410087039
GameObject:
m_ObjectHideFlags: 0
@@ -517,7 +782,7 @@ MonoBehaviour:
brushSize: 2
textureSize: 1024
baseColor: {r: 0.8, g: 0.8, b: 0.8, a: 1}
paddingTexels: 1
paddingTexels: 2
paintCamera: {fileID: 0}
updateColliderEveryFrame: 0
brushShader: {fileID: 0}
@@ -869,7 +1134,7 @@ GameObject:
- component: {fileID: 1141039642}
m_Layer: 0
m_Name: Player
m_TagString: Untagged
m_TagString: Player
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
@@ -888,6 +1153,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1944972203}
- {fileID: 1774267802}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!143 &1141039641
@@ -939,6 +1205,37 @@ MonoBehaviour:
slideAcceleration: 20
maxSlideSpeed: 8
slideControl: 0.3
--- !u!1 &1774267801
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1774267802}
m_Layer: 0
m_Name: CameraTarget
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1774267802
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1774267801}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1141039639}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &1944972203 stripped
Transform:
m_CorrespondingSourceObject: {fileID: -8679921383154817045, guid: 554c0bdf86263754d862d7effd04045b, type: 3}
@@ -1004,3 +1301,4 @@ SceneRoots:
- {fileID: 721670973}
- {fileID: 963088882}
- {fileID: 200502122}
- {fileID: 172071436}