movement update

This commit is contained in:
2026-06-02 10:00:42 +07:00
parent 1490ada744
commit b381bcef32
10 changed files with 850 additions and 677 deletions

View File

@@ -6,11 +6,15 @@
<component name="ChangeListManager">
<list default="true" id="f9183c68-daf0-43b8-be4c-fad79983f91b" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/.idea.HALLUCINATE/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.HALLUCINATE/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Invector-3rdPersonController/Basic Locomotion/Scripts/CharacterController/vThirdPersonInput.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Invector-3rdPersonController/Basic Locomotion/Scripts/CharacterController/vThirdPersonInput.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Invector-3rdPersonController/Melee Combat/Scripts/CharacterController/vMeleeCombatInput.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Invector-3rdPersonController/Melee Combat/Scripts/CharacterController/vMeleeCombatInput.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Invector-3rdPersonController/Shooter/Scripts/Shooter/vShooterMeleeInput.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Invector-3rdPersonController/Shooter/Scripts/Shooter/vShooterMeleeInput.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/Player Controller/InputReader.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/Player Controller/InputReader.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ProjectSettings/Packages/com.unity.probuilder/Settings.json" beforeDir="false" afterPath="$PROJECT_DIR$/ProjectSettings/Packages/com.unity.probuilder/Settings.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Prefabs/Player.prefab" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Prefabs/Player.prefab" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scenes/Cho môn AI/Only AI.unity" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scenes/Cho môn AI/Only AI.unity" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/AI NPC/GerminiNPC.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/AI NPC/GerminiNPC.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Settings/InputSystem_Actions.inputactions" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Settings/InputSystem_Actions.inputactions" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Third Parties/Invector-3rdPersonController/Basic Locomotion/Scripts/CharacterController/vThirdPersonInput.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Third Parties/Invector-3rdPersonController/Basic Locomotion/Scripts/CharacterController/vThirdPersonInput.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Third Parties/Invector-3rdPersonController/Melee Combat/Scripts/CharacterController/vMeleeCombatInput.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Third Parties/Invector-3rdPersonController/Melee Combat/Scripts/CharacterController/vMeleeCombatInput.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Third Parties/Invector-3rdPersonController/Shooter/Prefabs/Player/vShooterMelee_Inventory.prefab" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Third Parties/Invector-3rdPersonController/Shooter/Prefabs/Player/vShooterMelee_Inventory.prefab" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Third Parties/Invector-3rdPersonController/Shooter/Scripts/Shooter/vShooterMeleeInput.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Third Parties/Invector-3rdPersonController/Shooter/Scripts/Shooter/vShooterMeleeInput.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Third Parties/Invector-3rdPersonController/Shooter/Scripts/ThrowSystem/UI/CustomProjector/RangeIndicator.mat" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Third Parties/Invector-3rdPersonController/Shooter/Scripts/ThrowSystem/UI/CustomProjector/RangeIndicator.mat" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -18,7 +22,7 @@
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="EmbeddingIndexingInfo">
<option name="cachedIndexableFilesCount" value="28" />
<option name="cachedIndexableFilesCount" value="48" />
<option name="fileBasedEmbeddingIndicesEnabled" value="true" />
</component>
<component name="Git.Settings">
@@ -73,7 +77,7 @@
}</component>
<component name="RunManager" selected="Attach to Unity Editor.Attach to Unity Editor">
<configuration name="Standalone Player" type="RunUnityExe" factoryName="Unity Executable">
<option name="EXE_PATH" value="$PROJECT_DIR$/../Build test\HALLUCINATE.exe" />
<option name="EXE_PATH" value="$PROJECT_DIR$/Build\HALLUCINATE.exe" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="D:\BAI MUTIPLAY" />
<option name="PASS_PARENT_ENVS" value="1" />
@@ -102,7 +106,7 @@
<option name="MIXED_MODE_DEBUG" value="0" />
<method v="2" />
</configuration>
<configuration name="Attach to Unity Editor" type="UNITY_DEBUG_RUN_CONFIGURATION" factoryName="Unity Debug" show_console_on_std_err="false" show_console_on_std_out="false" port="50000" address="localhost">
<configuration name="Attach to Unity Editor" type="UNITY_DEBUG_RUN_CONFIGURATION" factoryName="Unity Debug" show_console_on_std_err="false" show_console_on_std_out="false" port="50000" address="localhost" useMixedMode="false">
<option name="allowRunningInParallel" value="false" />
<option name="listenPortForConnections" value="false" />
<option name="pid" />
@@ -113,7 +117,6 @@
<option name="selectedOptions">
<list />
</option>
<option name="useMixedMode" value="false" />
<method v="2" />
</configuration>
<configuration name="Attach to" type="UnityDevicePlayer" factoryName="UnityAttachToDevicePlayer">
@@ -176,6 +179,7 @@
<workItem from="1780140952531" duration="441000" />
<workItem from="1780141455151" duration="159000" />
<workItem from="1780141729457" duration="9450000" />
<workItem from="1780364354282" duration="4357000" />
</task>
<servers />
</component>

View File

@@ -68,7 +68,7 @@ MonoBehaviour:
forwardRayLength: 10
obstacleLayer:
serializedVersion: 2
m_Bits: 128
m_Bits: 0
heightRayLength: 0
interactionOffset: {x: 0, y: 1.5, z: 0}
interactionRadius: 0.5
@@ -592,9 +592,6 @@ MonoBehaviour:
<GroundMask>k__BackingField:
serializedVersion: 2
m_Bits: 0
_IsGrounded: 0
_WasGrounded: 0
_VelocityY: 0
_NetworkedPosition: {x: 0, y: 0, z: 0}
--- !u!114 &7730391503324595278
MonoBehaviour:
@@ -611,7 +608,10 @@ MonoBehaviour:
speedParamName: Speed
velocityXParamName: Velocity X
velocityZParamName: Velocity Z
groundedParamName: Grounded
animationDamping: 0.2
visualOffsetY: 0
modelTransform: {fileID: 0}
--- !u!1 &2962936552048247184
GameObject:
m_ObjectHideFlags: 0

View File

@@ -42104,6 +42104,37 @@ Transform:
m_Children: []
m_Father: {fileID: 333057066}
m_LocalEulerAnglesHint: {x: 0, y: -45, z: 90}
--- !u!1 &348410791
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 348410792}
m_Layer: 0
m_Name: SpawnPoint
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &348410792
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 348410791}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 5.7248, y: 1.5, z: -32.50002}
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 &365978100
GameObject:
m_ObjectHideFlags: 0
@@ -98903,128 +98934,6 @@ Mesh:
- serializedVersion: 1
m_IndexStart: 0
m_IndexCount: 0
--- !u!1001 &779176738
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: -5076913349690967641, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
propertyPath: SortKey
value: 2747909713
objectReference: {fileID: 0}
- target: {fileID: 1054594849095937263, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
propertyPath: m_Name
value: Player
objectReference: {fileID: 0}
- target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
propertyPath: m_LocalPosition.x
value: 0.9289999
objectReference: {fileID: 0}
- target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
propertyPath: m_LocalPosition.y
value: 0.5
objectReference: {fileID: 0}
- target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
propertyPath: m_LocalPosition.z
value: -28
objectReference: {fileID: 0}
- target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3154409663696148700, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5811177247042239962, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
propertyPath: obstacleLayer.m_Bits
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 761bdf2e5c0cff4488527355acb975e5, type: 3}
--- !u!1001 &788944362
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
serializedVersion: 3
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 2207112960010484425, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
propertyPath: m_LocalPosition.x
value: 18.5
objectReference: {fileID: 0}
- target: {fileID: 2207112960010484425, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
propertyPath: m_LocalPosition.y
value: 9.14399
objectReference: {fileID: 0}
- target: {fileID: 2207112960010484425, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
propertyPath: m_LocalPosition.z
value: -38.84505
objectReference: {fileID: 0}
- target: {fileID: 2207112960010484425, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 2207112960010484425, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2207112960010484425, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2207112960010484425, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2207112960010484425, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2207112960010484425, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2207112960010484425, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2771692228748849855, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
propertyPath: m_Name
value: Main Camera
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
m_AddedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: fb7874830b9e56341bf88f2a1123c677, type: 3}
--- !u!1 &796819780
GameObject:
m_ObjectHideFlags: 0
@@ -127102,6 +127011,66 @@ Mesh:
- serializedVersion: 1
m_IndexStart: 0
m_IndexCount: 0
--- !u!1 &1098531124
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1098531126}
- component: {fileID: 1098531125}
m_Layer: 0
m_Name: GameController
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1098531125
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1098531124}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f8a5c95eb7ab7db4f9f2151bae646701, type: 3}
m_Name:
m_EditorClassIdentifier: Assembly-CSharp::Invector.vGameController
openCloseEvents: 0
openCloseWindow: 0
selectedToolbar: 0
playerPrefab: {fileID: 146720, guid: 092f8aa667b2004459042a82a4c9e41d, type: 3}
spawnPoint: {fileID: 348410792}
respawnTimer: 4
destroyBodyAfterDead: 0
displayInfoInFadeText: 1
OnReloadGame:
m_PersistentCalls:
m_Calls: []
currentPlayer: {fileID: 0}
onSpawn:
m_PersistentCalls:
m_Calls: []
dontDestroyOnLoad: 1
--- !u!4 &1098531126
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1098531124}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -16.49995, y: 10.56881, z: 19.27294}
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 &1143870345
GameObject:
m_ObjectHideFlags: 0
@@ -138503,6 +138472,85 @@ Mesh:
- serializedVersion: 1
m_IndexStart: 0
m_IndexCount: 0
--- !u!1 &1793734342
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1793734345}
- component: {fileID: 1793734344}
- component: {fileID: 1793734343}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1793734343
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1793734342}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.InputSystem::UnityEngine.InputSystem.UI.InputSystemUIInputModule
m_SendPointerHoverToParent: 1
m_MoveRepeatDelay: 0.5
m_MoveRepeatRate: 0.1
m_XRTrackingOrigin: {fileID: 0}
m_ActionsAsset: {fileID: -944628639613478452, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_PointAction: {fileID: -1654692200621890270, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_MoveAction: {fileID: -8784545083839296357, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_SubmitAction: {fileID: 392368643174621059, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_CancelAction: {fileID: 7727032971491509709, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_LeftClickAction: {fileID: 3001919216989983466, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_MiddleClickAction: {fileID: -2185481485913320682, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_RightClickAction: {fileID: -4090225696740746782, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_ScrollWheelAction: {fileID: 6240969308177333660, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_TrackedDevicePositionAction: {fileID: 6564999863303420839, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_TrackedDeviceOrientationAction: {fileID: 7970375526676320489, guid: ca9f5fa95ffab41fb9a615ab714db018, type: 3}
m_DeselectOnBackgroundClick: 1
m_PointerBehavior: 0
m_CursorLockBehavior: 0
m_ScrollDeltaPerTick: 6
--- !u!114 &1793734344
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1793734342}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.EventSystems.EventSystem
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 10
--- !u!4 &1793734345
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1793734342}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
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!43 &1820026756
Mesh:
m_ObjectHideFlags: 0
@@ -142099,7 +142147,8 @@ SceneRoots:
m_ObjectHideFlags: 0
m_Roots:
- {fileID: 678938550}
- {fileID: 788944362}
- {fileID: 779176738}
- {fileID: 333057066}
- {fileID: 460076050}
- {fileID: 1098531126}
- {fileID: 348410792}
- {fileID: 1793734345}

View File

@@ -28,7 +28,8 @@ public class GeminiResponse
{
public Candidate[] candidates;
}
public class GerminiNPC :MonoBehaviour
public class GerminiNPC : MonoBehaviour
{
[SerializeField]
private string apiKey = "AQ.Ab8RN6I2hU_p8yHiPNNHtWzYBiLugbPP22gC6lzTWaYEWj4v0g";
@@ -37,46 +38,96 @@ public class GerminiNPC :MonoBehaviour
"https://generativelanguage.googleapis.com/v1beta/models/gemini-flash-latest:generateContent";
public string npcPersona =
$"Nguơi là ột thợ lão thợ rèn cọc cằn tên là TOm,ngươi rất ghét những kẻ mang phế liệu đến tiệm của mình.Ch trả lời ngắn gọn trong 2 câu,theo phong cách trung cổ";
"Ngươi là một lão thợ rèn cọc cằn tên là Tom, ngươi rất ghét những kẻ mang phế liệu đến tiệm của mình. Ch trả lời ngắn gọn trong 2 câu, theo phong cách trung cổ.";
public string playerHeldItem = "Thanh kiếm rỉ sét";
public float interactionDistance = 5f; // Khoảng cách tối đa để nói chuyện
public Transform playerTransform; // Gán transform của Player vào đây
private void Update()
{
if (Keyboard.current.spaceKey.wasPressedThisFrame)
if (Keyboard.current != null && Keyboard.current.fKey.wasPressedThisFrame)
{
StartCoroutine(GetGerminiReponse());
if (CanSeePlayer())
{
StartCoroutine(GetGerminiReponse());
}
else
{
Debug.Log("<color=yellow>Hệ thống:</color> Bạn ở quá xa hoặc bị tường che khuất!");
}
}
}
private bool CanSeePlayer()
{
if (playerTransform == null)
{
// Tự tìm player nếu chưa gán
GameObject player = GameObject.FindGameObjectWithTag("Player");
if (player != null) playerTransform = player.transform;
else return false;
}
// 1. Check khoảng cách
float dist = Vector3.Distance(transform.position, playerTransform.position);
if (dist > interactionDistance) return false;
// 2. Check xem có bị tường che không (Raycast)
Vector3 direction = (playerTransform.position + Vector3.up) - (transform.position + Vector3.up);
RaycastHit hit;
if (Physics.Raycast(transform.position + Vector3.up, direction, out hit, interactionDistance))
{
if (hit.collider.CompareTag("Player") || hit.collider.transform.IsChildOf(playerTransform))
{
return true; // Thấy đầu/người player
}
}
return false;
}
private IEnumerator GetGerminiReponse()
{
var jsonBody = $@"{{""systemInstruction"": {{""parts"": [{{ ""text"": ""{npcPersona}"" }}]}},
""contents"": [{{""parts"": [{{ ""text"": ""Ta muốn bán cho ông món đồ này cho ông {playerHeldItem}""}}]}}] }} ";
var requestURL = $"{germiniURL}?ket={apiKey}";
using (var request = new UnityWebRequest(germiniURL, "POST"))
var jsonBody = $@"{{
""systemInstruction"": {{""parts"": [{{ ""text"": ""{npcPersona}"" }}]}},
""contents"": [{{""parts"": [{{ ""text"": ""Ta muốn bán cho ông món đồ này: {playerHeldItem}""}}]}}]
}}";
// 1. Sửa tham số thành ?key= (trước đó là ?ket=)
var requestURL = $"{germiniURL}?key={apiKey}";
// 2. Sử dụng requestURL (có chứa key) thay vì germiniURL gốc
using (var request = new UnityWebRequest(requestURL, "POST"))
{
var bodyRaw = Encoding.UTF8.GetBytes(jsonBody);
request.uploadHandler = new UploadHandlerRaw(bodyRaw);
request.downloadHandler = new DownloadHandlerBuffer();
request.SetRequestHeader("Content-Type", "application/json");
yield return request.SendWebRequest();
if (request.result == UnityWebRequest.Result.ProtocolError)
if (request.result == UnityWebRequest.Result.ProtocolError || request.result == UnityWebRequest.Result.ConnectionError)
{
Debug.LogError(request.error);
Debug.LogError($"[Gemini Error] {request.error} - Response: {request.downloadHandler.text}");
}
else
{
var responseTEXT = request.downloadHandler.text;
var germiniResponse=JsonUtility.FromJson<GeminiResponse>(responseTEXT);
if (germiniResponse.candidates.Length > 0)
try
{
var npcResponse = germiniResponse.candidates[0].content.parts[0].text;
Debug.Log(npcResponse);
var geminiResponse = JsonUtility.FromJson<GeminiResponse>(responseTEXT);
if (geminiResponse != null && geminiResponse.candidates != null && geminiResponse.candidates.Length > 0)
{
var npcResponse = geminiResponse.candidates[0].content.parts[0].text;
Debug.Log($"<color=green>Tom:</color> {npcResponse}");
}
}
catch (Exception e)
{
Debug.LogError($"[JSON Parse Error] {e.Message}");
}
}
}
}
}

View File

@@ -255,7 +255,7 @@
"id": "8c8e490b-c610-4785-884f-f04217b23ca4",
"path": "<Pointer>/delta",
"interactions": "",
"processors": "",
"processors": "ScaleVector2(x=0.01,y=0.01)",
"groups": ";Keyboard&Mouse;Touch",
"action": "Look",
"isComposite": false,

View File

@@ -616,8 +616,8 @@ namespace Invector.vCharacterController
// var Y = lockCameraInput ? 0f : rotateCameraYInput.GetAxis();
// var X = lockCameraInput ? 0f : rotateCameraXInput.GetAxis();
var Y = lockCameraInput ? 0f : inputReader.LookInput.y;
var X = lockCameraInput ? 0f : inputReader.LookInput.x;
var Y = lockCameraInput ? 0f : inputReader.LookInput.y * tpCamera.currentState.yMouseSensitivity;
var X = lockCameraInput ? 0f : inputReader.LookInput.x * tpCamera.currentState.xMouseSensitivity;
if (invertCameraInputHorizontal) X *= -1;
if (invertCameraInputVertical) Y *= -1;

View File

@@ -155,7 +155,7 @@ namespace Invector.vCharacterController
}
// isBlocking = blockInput.GetButton() && cc.currentStamina > 0 && !cc.customAction && !isAttacking;
isBlocking = inputReader.IsBlockHeld && cc.currentStamina > 0 && !cc.customAction && !isAttacking;
isBlocking = inputReader != null && inputReader.IsBlockHeld && cc.currentStamina > 0 && !cc.customAction && !isAttacking;
}
/// <summary>

View File

@@ -678,7 +678,7 @@ namespace Invector.vCharacterController
// {
// _aimTiming = 0f;
// }
if(inputReader.IsSprintHeld && _aimTiming > 0f)
if(inputReader != null && inputReader.IsSprintHeld && _aimTiming > 0f)
{
_aimTiming = 0f;
}

View File

@@ -32,13 +32,13 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 2800000, guid: db48e0e5caa2999469a4f3aa249c188b, type: 3}
m_Texture: {fileID: 2800000, guid: 1ba5636bfdd687347966f548dbf5a0bc, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats: []
m_Colors:
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 8, g: 0, b: 0, a: 1}
- _Vector0: {r: 1, g: 1, b: 0, a: 0}
m_BuildTextureStacks: []
m_AllowLocking: 1