Hide objects in front of player

This commit is contained in:
Vladimir Koshevarov
2022-11-17 19:20:24 +02:00
parent ed1c16db33
commit be23c9fa96
4 changed files with 183 additions and 102 deletions
+151 -94
View File
@@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 705507994}
m_IndirectSpecularColor: {r: 0.44657826, g: 0.49641263, b: 0.57481676, a: 1}
m_IndirectSpecularColor: {r: 0.4496541, g: 0.4997235, b: 0.57564855, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
@@ -3248,7 +3248,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 2649ed9748ff3864880311f1c2aecdef, type: 3}
m_Name:
m_EditorClassIdentifier:
_playerController: {fileID: 1476341271}
_playerController: {fileID: 871823188}
_timeText: {fileID: 2089282903}
_moneyText: {fileID: 443940496}
_energy: {fileID: 910851332}
@@ -3633,10 +3633,10 @@ Light:
m_Type: 2
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 0.302
m_Bias: 0.06
m_NormalBias: 0.12
m_NearPlane: 0.1
m_Strength: 1
m_Bias: 0.02
m_NormalBias: 0.16
m_NearPlane: 0.5
m_CullingMatrixOverride:
e00: 1
e01: 0
@@ -3656,7 +3656,7 @@ Light:
e33: 1
m_UseCullingMatrixOverride: 0
m_Cookie: {fileID: 0}
m_DrawHalo: 0
m_DrawHalo: 1
m_Flare: {fileID: 0}
m_RenderMode: 0
m_CullingMask:
@@ -3673,7 +3673,7 @@ Light:
m_UseBoundingSphereOverride: 0
m_UseViewFrustumForShadowCasterCull: 1
m_ShadowRadius: 0
m_ShadowAngle: 0
m_ShadowAngle: 9.2
--- !u!4 &705507995
Transform:
m_ObjectHideFlags: 0
@@ -3681,14 +3681,14 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705507993}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: -200.71999, y: -477.22424, z: 0.6698125}
m_LocalRotation: {x: 0.13156042, y: 0.92744404, z: -0.34980756, w: -0.013194327}
m_LocalPosition: {x: 0, y: 50, z: 50}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1504187455}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
m_LocalEulerAnglesHint: {x: 40.194, y: 188.774, z: 19.363}
--- !u!1 &712058891
GameObject:
m_ObjectHideFlags: 0
@@ -3998,6 +3998,132 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 779251533}
m_CullTransparentMesh: 1
--- !u!1 &871823183
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 871823189}
- component: {fileID: 871823188}
- component: {fileID: 871823187}
- component: {fileID: 871823186}
- component: {fileID: 871823185}
- component: {fileID: 871823184}
m_Layer: 0
m_Name: Player
m_TagString: Player
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!195 &871823184
NavMeshAgent:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 871823183}
m_Enabled: 1
m_AgentTypeID: 0
m_Radius: 0.3
m_Speed: 1.75
m_Acceleration: 60
avoidancePriority: 50
m_AngularSpeed: 600
m_StoppingDistance: 0.1
m_AutoTraverseOffMeshLink: 1
m_AutoBraking: 1
m_AutoRepath: 1
m_Height: 1.2
m_BaseOffset: 0
m_WalkableMask: 4294967295
m_ObstacleAvoidanceType: 4
--- !u!95 &871823185
Animator:
serializedVersion: 4
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 871823183}
m_Enabled: 1
m_Avatar: {fileID: 0}
m_Controller: {fileID: 9100000, guid: 6abd17ae3669e8d448186fd24a2aadb7, type: 2}
m_CullingMode: 0
m_UpdateMode: 0
m_ApplyRootMotion: 0
m_LinearVelocityBlending: 0
m_StabilizeFeet: 0
m_WarningMessage:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0
--- !u!136 &871823186
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 871823183}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
m_Radius: 0.3
m_Height: 1.2
m_Direction: 1
m_Center: {x: 0, y: 0.6, z: 0}
--- !u!54 &871823187
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 871823183}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!114 &871823188
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 871823183}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c802a0d9d32b0c04b841113e87b83e4b, type: 3}
m_Name:
m_EditorClassIdentifier:
player: {fileID: 871823184}
playerAnimator: {fileID: 1476341268}
playerCamera: {fileID: 963194227}
targetDest: {fileID: 1359374190}
allowMovement: 1
--- !u!4 &871823189
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 871823183}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 1.86}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1476341267}
m_Father: {fileID: 0}
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &875821251
GameObject:
m_ObjectHideFlags: 0
@@ -4103,11 +4229,11 @@ PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_TransformParent: {fileID: 871823189}
m_Modifications:
- target: {fileID: -8679921383154817045, guid: 32790d47acc86814982f18993097a759, type: 3}
propertyPath: m_RootOrder
value: 8
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 32790d47acc86814982f18993097a759, type: 3}
propertyPath: m_LocalScale.x
@@ -4123,11 +4249,11 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 32790d47acc86814982f18993097a759, type: 3}
propertyPath: m_LocalPosition.x
value: 1.394
value: 0
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 32790d47acc86814982f18993097a759, type: 3}
propertyPath: m_LocalPosition.y
value: 0.022
value: -0.04
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 32790d47acc86814982f18993097a759, type: 3}
propertyPath: m_LocalPosition.z
@@ -4487,7 +4613,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 919132149155446097, guid: 32790d47acc86814982f18993097a759, type: 3}
propertyPath: m_Name
value: Player
value: Sophie
objectReference: {fileID: 0}
- target: {fileID: 1092408308860062549, guid: 32790d47acc86814982f18993097a759, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
@@ -5240,14 +5366,14 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 963194225}
m_LocalRotation: {x: 0.327264, y: -0, z: -0, w: 0.94493294}
m_LocalPosition: {x: 0.688, y: 3.213, z: -2.087}
m_LocalRotation: {x: 0.26147237, y: -0, z: -0, w: 0.965211}
m_LocalPosition: {x: 0, y: 2.947, z: -1.601}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 38.206, y: 0, z: 0}
m_LocalEulerAnglesHint: {x: 30.315, y: 0, z: 0}
--- !u!114 &963194229
MonoBehaviour:
m_ObjectHideFlags: 0
@@ -5260,7 +5386,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: a4e1e654ad8309241b3a54f10170ea2c, type: 3}
m_Name:
m_EditorClassIdentifier:
_playerTransform: {fileID: 1476341267}
_player: {fileID: 871823189}
_smoothFactor: 0.5
--- !u!1 &1006389536
GameObject:
@@ -6204,7 +6330,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1232329904}
m_LocalRotation: {x: 0.495267, y: 0.5046887, z: 0.5046887, w: 0.495267}
m_LocalPosition: {x: 7.81, y: -3.45, z: -1.11}
m_LocalPosition: {x: 5.84, y: -3.487, z: -1.11}
m_LocalScale: {x: 2.8920708, y: 2.1952477, z: 2.542238}
m_ConstrainProportionsScale: 0
m_Children: []
@@ -7203,7 +7329,7 @@ ParticleSystem:
m_PostInfinity: 2
m_RotationOrder: 4
randomizeRotationDirection: 0
maxNumParticles: 1000
maxNumParticles: 1
customEmitterVelocity: {x: 0, y: 0, z: 0}
size3D: 0
rotation3D: 0
@@ -11413,7 +11539,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 9
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
--- !u!1 &1366991730
GameObject:
@@ -11576,75 +11702,6 @@ Animator:
m_HasTransformHierarchy: 1
m_AllowConstantClipSamplingOptimization: 1
m_KeepAnimatorControllerStateOnDisable: 0
--- !u!195 &1476341269
NavMeshAgent:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1476341266}
m_Enabled: 1
m_AgentTypeID: 0
m_Radius: 0.5
m_Speed: 1.75
m_Acceleration: 60
avoidancePriority: 50
m_AngularSpeed: 600
m_StoppingDistance: 0
m_AutoTraverseOffMeshLink: 1
m_AutoBraking: 1
m_AutoRepath: 1
m_Height: 2
m_BaseOffset: 0
m_WalkableMask: 4294967295
m_ObstacleAvoidanceType: 4
--- !u!136 &1476341270
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1476341266}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
m_Radius: 0.5
m_Height: 2
m_Direction: 1
m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &1476341271
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1476341266}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c802a0d9d32b0c04b841113e87b83e4b, type: 3}
m_Name:
m_EditorClassIdentifier:
player: {fileID: 1476341269}
playerAnimator: {fileID: 1476341268}
playerCamera: {fileID: 963194227}
targetDest: {fileID: 1359374190}
allowMovement: 1
--- !u!54 &1476341273
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1476341266}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 1
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!1 &1504187454
GameObject:
m_ObjectHideFlags: 0
@@ -11669,7 +11726,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1504187454}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 200.71999, y: 577.22424, z: -0.6698125}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
@@ -12778,7 +12835,7 @@ MonoBehaviour:
_title: {fileID: 107380538}
_choiceButton: {fileID: 890493768}
_closeBtn: {fileID: 1396013895}
_playerManager: {fileID: 1476341271}
_playerManager: {fileID: 871823188}
conversationChangeEvent:
m_PersistentCalls:
m_Calls:
+26 -4
View File
@@ -3,24 +3,46 @@ using UnityEngine;
public class CameraPlayerFollow : MonoBehaviour
{
[SerializeField]
private Transform _playerTransform;
private Transform _player;
private Vector3 _cameraOffset;
private Transform _obstruction;
[SerializeField]
[Range(0.01f, 1.0f)]
private float _smoothFactor = 0.5f;
// Start is called before the first frame update
void Start()
{
_cameraOffset = transform.position - _playerTransform.position;
transform.LookAt(_playerTransform);
_obstruction = null;
_cameraOffset = transform.position - _player.position;
transform.LookAt(_player);
}
void LateUpdate()
{
Vector3 newPosition = _playerTransform.position + _cameraOffset;
Vector3 newPosition = _player.position + _cameraOffset;
transform.position = Vector3.Slerp(transform.position, newPosition, _smoothFactor);
ViewObstructed();
}
private void ViewObstructed()
{
RaycastHit hit;
if (Physics.Raycast(transform.position, _player.position - transform.position, out hit, 1.5f))
{
if (hit.collider.gameObject.tag != "Player")
{
_obstruction = hit.transform;
_obstruction.gameObject.GetComponent<MeshRenderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly;
}
}
else if (_obstruction != null)
{
_obstruction.gameObject.GetComponent<MeshRenderer>().shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.On;
_obstruction = null;
}
}
}
+4 -3
View File
@@ -9,7 +9,7 @@ public class PlayerManager : MonoBehaviour
public Stat money = new Stat("Money", 100.0f);
public Stat rentAccount = new Stat("Rent Account", 0);
public Stat food = new Stat("Food Energy", 100);
public Stat energy = new Stat("Energy", 12);
public Stat energy = new Stat("Energy", 100);
// bank
public Stat bankAccount = new Stat("Bank Account", 0);
@@ -73,12 +73,13 @@ public class PlayerManager : MonoBehaviour
if (Input.GetMouseButton(0))
{
Ray myRay = playerCamera.ScreenPointToRay(Input.mousePosition);
targetDest.Stop();
if (Physics.Raycast(myRay, out RaycastHit hit))
{
targetDest.transform.position = hit.point;
targetDest.Play();
player.SetDestination(hit.point);
targetDest.Play();
}
}
}
+2 -1
View File
@@ -3,7 +3,8 @@
--- !u!78 &1
TagManager:
serializedVersion: 2
tags: []
tags:
- Building
layers:
- Default
- TransparentFX