finsihed castle walls, adding attack, block and kick aniamtions and input. Started on NPCdiagloue system
This commit is contained in:
@@ -21,8 +21,34 @@ AnimatorState:
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: -2702400367771620057, guid: 063aa479676c4084ebf187660ca0a7b8,
|
||||
type: 3}
|
||||
m_Motion: {fileID: -2702400367771620057, guid: 063aa479676c4084ebf187660ca0a7b8, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1102 &-7299084705008557981
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Attack
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: -4576905161438472570}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: -203655887218126122, guid: 0a7bc29fda59400429d996fe1a7497d5, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
@@ -49,12 +75,21 @@ AnimatorStateMachine:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 2316907928501487792}
|
||||
m_Position: {x: 0, y: 490, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -7299084705008557981}
|
||||
m_Position: {x: -50, y: 330, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: -367918734564721146}
|
||||
m_Position: {x: 440, y: 320, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 2832742685596528579}
|
||||
m_Position: {x: -50, y: 250, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions: []
|
||||
m_EntryTransitions: []
|
||||
m_StateMachineTransitions: {}
|
||||
m_StateMachineBehaviours: []
|
||||
m_AnyStatePosition: {x: 10, y: 330, z: 0}
|
||||
m_AnyStatePosition: {x: 20, y: 140, z: 0}
|
||||
m_EntryPosition: {x: 220, y: 330, z: 0}
|
||||
m_ExitPosition: {x: 680, y: 260, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
@@ -131,6 +166,50 @@ AnimatorStateTransition:
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &-4576905161438472570
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions: []
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 6904719651407550685}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.8333334
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &-4351357445173995075
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions: []
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 2832742685596528579}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.8857868
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &-3943826829571047522
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
@@ -181,6 +260,31 @@ AnimatorStateTransition:
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &-2209314075566250895
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Attack
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -7299084705008557981}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.8857868
|
||||
m_HasExitTime: 0
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &-1645763842379584696
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
@@ -233,6 +337,33 @@ AnimatorStateTransition:
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &-367918734564721146
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Block
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: 9083447699991651628}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: -203655887218126122, guid: 9d40b8b60b4152349a23af0ce5f72a93, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!91 &9100000
|
||||
AnimatorController:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -247,31 +378,49 @@ AnimatorController:
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Jump
|
||||
m_Type: 4
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Grounded
|
||||
m_Type: 4
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: FreeFall
|
||||
m_Type: 4
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: MotionSpeed
|
||||
m_Type: 1
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 0}
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Attack
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Block
|
||||
m_Type: 4
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
- m_Name: Kick
|
||||
m_Type: 9
|
||||
m_DefaultFloat: 0
|
||||
m_DefaultInt: 0
|
||||
m_DefaultBool: 0
|
||||
m_Controller: {fileID: 9100000}
|
||||
m_AnimatorLayers:
|
||||
- serializedVersion: 5
|
||||
m_Name: Base Layer
|
||||
@@ -353,8 +502,7 @@ AnimatorState:
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: -4506558747437489242, guid: d3b2083e086810047ab04d540db8afbc,
|
||||
type: 3}
|
||||
m_Motion: {fileID: -4506558747437489242, guid: d3b2083e086810047ab04d540db8afbc, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
@@ -403,8 +551,7 @@ AnimatorState:
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7478122292733868173, guid: 98f277b0c8055e143b2fcf058d3c27dc,
|
||||
type: 3}
|
||||
m_Motion: {fileID: 7478122292733868173, guid: 98f277b0c8055e143b2fcf058d3c27dc, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
@@ -432,6 +579,33 @@ AnimatorStateTransition:
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1102 &2832742685596528579
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Kick
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions:
|
||||
- {fileID: 8528589545817178478}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: -203655887218126122, guid: 51e78fe1b36d261499c98706dda981ab, type: 3}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1101 &5185278855704465556
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
@@ -470,6 +644,9 @@ AnimatorState:
|
||||
m_Transitions:
|
||||
- {fileID: -4639224020698590961}
|
||||
- {fileID: 8635457214972911529}
|
||||
- {fileID: -2209314075566250895}
|
||||
- {fileID: 8459640363602897088}
|
||||
- {fileID: -4351357445173995075}
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 1
|
||||
@@ -535,6 +712,56 @@ AnimatorStateTransition:
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &8459640363602897088
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Block
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: -367918734564721146}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.8857868
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!1101 &8528589545817178478
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 1
|
||||
m_ConditionEvent: Kick
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 6904719651407550685}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.7887324
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
--- !u!206 &8571049798372811705
|
||||
BlendTree:
|
||||
m_ObjectHideFlags: 1
|
||||
@@ -544,8 +771,7 @@ BlendTree:
|
||||
m_Name: Blend Tree
|
||||
m_Childs:
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: -3100369314251171874, guid: 12e52e465ed793a4d801955e9f964a82,
|
||||
type: 3}
|
||||
m_Motion: {fileID: -3100369314251171874, guid: 12e52e465ed793a4d801955e9f964a82, type: 3}
|
||||
m_Threshold: 0
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1
|
||||
@@ -553,8 +779,7 @@ BlendTree:
|
||||
m_DirectBlendParameter: Speed
|
||||
m_Mirror: 0
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: 1657602633327794031, guid: 8269a9f8cf495034c817722ac21f309f,
|
||||
type: 3}
|
||||
m_Motion: {fileID: 1657602633327794031, guid: 8269a9f8cf495034c817722ac21f309f, type: 3}
|
||||
m_Threshold: 2
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1
|
||||
@@ -562,8 +787,7 @@ BlendTree:
|
||||
m_DirectBlendParameter: Speed
|
||||
m_Mirror: 0
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: 6564411413370888346, guid: 16114d403eabb53438de032c6f0d1deb,
|
||||
type: 3}
|
||||
m_Motion: {fileID: 6564411413370888346, guid: 16114d403eabb53438de032c6f0d1deb, type: 3}
|
||||
m_Threshold: 6
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1
|
||||
@@ -611,8 +835,7 @@ BlendTree:
|
||||
m_Name: Blend Tree
|
||||
m_Childs:
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: -9098803823909532060, guid: 98f277b0c8055e143b2fcf058d3c27dc,
|
||||
type: 3}
|
||||
m_Motion: {fileID: -9098803823909532060, guid: 98f277b0c8055e143b2fcf058d3c27dc, type: 3}
|
||||
m_Threshold: 0
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1
|
||||
@@ -620,8 +843,7 @@ BlendTree:
|
||||
m_DirectBlendParameter: Speed
|
||||
m_Mirror: 0
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: 3062299877480904481, guid: 325a26d62b61fa94cb3c97c435efebc5,
|
||||
type: 3}
|
||||
m_Motion: {fileID: 3062299877480904481, guid: 325a26d62b61fa94cb3c97c435efebc5, type: 3}
|
||||
m_Threshold: 2
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1
|
||||
@@ -629,8 +851,7 @@ BlendTree:
|
||||
m_DirectBlendParameter: Speed
|
||||
m_Mirror: 0
|
||||
- serializedVersion: 2
|
||||
m_Motion: {fileID: -2817517482862745934, guid: 3c033631149b9c541bcf155cd94cccba,
|
||||
type: 3}
|
||||
m_Motion: {fileID: -2817517482862745934, guid: 3c033631149b9c541bcf155cd94cccba, type: 3}
|
||||
m_Threshold: 6
|
||||
m_Position: {x: 0, y: 0}
|
||||
m_TimeScale: 1
|
||||
@@ -644,3 +865,28 @@ BlendTree:
|
||||
m_UseAutomaticThresholds: 0
|
||||
m_NormalizedBlendValues: 0
|
||||
m_BlendType: 0
|
||||
--- !u!1101 &9083447699991651628
|
||||
AnimatorStateTransition:
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_Conditions:
|
||||
- m_ConditionMode: 2
|
||||
m_ConditionEvent: Block
|
||||
m_EventTreshold: 0
|
||||
m_DstStateMachine: {fileID: 0}
|
||||
m_DstState: {fileID: 6904719651407550685}
|
||||
m_Solo: 0
|
||||
m_Mute: 0
|
||||
m_IsExit: 0
|
||||
serializedVersion: 3
|
||||
m_TransitionDuration: 0.25
|
||||
m_TransitionOffset: 0
|
||||
m_ExitTime: 0.8192771
|
||||
m_HasExitTime: 1
|
||||
m_HasFixedDuration: 1
|
||||
m_InterruptionSource: 0
|
||||
m_OrderedInterruption: 1
|
||||
m_CanTransitionToSelf: 1
|
||||
|
||||
@@ -14,6 +14,11 @@ namespace StarterAssets
|
||||
#endif
|
||||
public class ThirdPersonController : MonoBehaviour
|
||||
{
|
||||
|
||||
[Header("Animation")]
|
||||
[Tooltip("Animator component reference")]
|
||||
public Animator Animator;
|
||||
|
||||
[Header("Player")]
|
||||
[Tooltip("Move speed of the character in m/s")]
|
||||
public float MoveSpeed = 2.0f;
|
||||
@@ -98,6 +103,8 @@ namespace StarterAssets
|
||||
private int _animIDFreeFall;
|
||||
private int _animIDMotionSpeed;
|
||||
|
||||
private Transform _currentTarget; // Track the currently targeted object
|
||||
|
||||
#if ENABLE_INPUT_SYSTEM
|
||||
private PlayerInput _playerInput;
|
||||
#endif
|
||||
@@ -159,6 +166,29 @@ namespace StarterAssets
|
||||
JumpAndGravity();
|
||||
GroundedCheck();
|
||||
Move();
|
||||
|
||||
CheckForObjectInformation(); // Call the new Raycast function
|
||||
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
PlayerAttack(); // Call the attack function when the left mouse button is pressed
|
||||
} // Left mouse button
|
||||
|
||||
// Block when the right mouse button is pressed
|
||||
if (Input.GetMouseButton(1))
|
||||
{
|
||||
PlayerBlock(); // Start the block animation
|
||||
}
|
||||
else
|
||||
{
|
||||
Animator.SetBool("Block", false); // Stop the block animation when the button is released
|
||||
}
|
||||
|
||||
if (Input.GetKeyUp(KeyCode.F))
|
||||
{
|
||||
PlayerKick(); // Call the kick function when the F button is pressed
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
@@ -211,6 +241,41 @@ namespace StarterAssets
|
||||
_cinemachineTargetYaw, 0.0f);
|
||||
}
|
||||
|
||||
private void CheckForObjectInformation()
|
||||
{
|
||||
// Define the sphere cast starting point and direction
|
||||
Vector3 origin = transform.position;
|
||||
Vector3 direction = transform.forward;
|
||||
float sphereRadius = 0.5f; // Adjust the radius as needed
|
||||
float maxDistance = 4.0f; // Adjust the distance as needed
|
||||
RaycastHit hit;
|
||||
|
||||
// Perform the sphere cast
|
||||
if (Physics.SphereCast(origin, sphereRadius, direction, out hit, maxDistance))
|
||||
{
|
||||
// Check if the hit object has the ObjectInformation component
|
||||
ObjectInformation objectInfo = hit.collider.GetComponent<ObjectInformation>();
|
||||
if (objectInfo != null)
|
||||
{
|
||||
// If the player is looking at a new object, update the pop-up
|
||||
if (_currentTarget != hit.transform)
|
||||
{
|
||||
_currentTarget = hit.transform; // Update the current target
|
||||
PopUpManager.instance.ShowPopUp(objectInfo.objectName, objectInfo.objectDescription, hit.transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the sphere cast doesn't hit anything, hide the pop-up
|
||||
if (_currentTarget != null)
|
||||
{
|
||||
_currentTarget = null; // Clear the current target
|
||||
PopUpManager.instance.gameObject.SetActive(false); // Hide the pop-up
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Move()
|
||||
{
|
||||
// set target speed based on move speed, sprint speed and if sprint is pressed
|
||||
@@ -388,5 +453,19 @@ namespace StarterAssets
|
||||
AudioSource.PlayClipAtPoint(LandingAudioClip, transform.TransformPoint(_controller.center), FootstepAudioVolume);
|
||||
}
|
||||
}
|
||||
public void PlayerAttack()
|
||||
{
|
||||
Animator.SetTrigger("Attack");
|
||||
}
|
||||
|
||||
public void PlayerBlock()
|
||||
{
|
||||
Animator.SetBool("Block", true);
|
||||
}
|
||||
|
||||
public void PlayerKick()
|
||||
{
|
||||
Animator.SetTrigger("Kick");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user