diff --git a/Assets/Polyart/PolyartStudio/DreamscapeCastle/Scenes/Gameplay.unity b/Assets/Polyart/PolyartStudio/DreamscapeCastle/Scenes/Gameplay.unity index ccec5931..69d39e7e 100644 --- a/Assets/Polyart/PolyartStudio/DreamscapeCastle/Scenes/Gameplay.unity +++ b/Assets/Polyart/PolyartStudio/DreamscapeCastle/Scenes/Gameplay.unity @@ -100092,7 +100092,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 630530476} - m_Layer: 0 + m_Layer: 8 m_Name: AbilityCastPoint m_TagString: Untagged m_Icon: {fileID: 0} @@ -355507,11 +355507,21 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 2191382144852172495, guid: 576abe9759f86e542b8cee9ae2f0ffd7, + type: 3} + propertyPath: m_Layer + value: 8 + objectReference: {fileID: 0} - target: {fileID: 3960509566317876621, guid: 576abe9759f86e542b8cee9ae2f0ffd7, type: 3} propertyPath: m_Name value: Character objectReference: {fileID: 0} + - target: {fileID: 3960509566317876621, guid: 576abe9759f86e542b8cee9ae2f0ffd7, + type: 3} + propertyPath: m_Layer + value: 8 + objectReference: {fileID: 0} - target: {fileID: 4580555029999605212, guid: 576abe9759f86e542b8cee9ae2f0ffd7, type: 3} propertyPath: manaFillImage diff --git a/Assets/Polyart/PolyartStudio/SharedResources/Scripts/Gameplay/Character/FirstPersonController.cs b/Assets/Polyart/PolyartStudio/SharedResources/Scripts/Gameplay/Character/FirstPersonController.cs index 118f833d..20e4d0b7 100644 --- a/Assets/Polyart/PolyartStudio/SharedResources/Scripts/Gameplay/Character/FirstPersonController.cs +++ b/Assets/Polyart/PolyartStudio/SharedResources/Scripts/Gameplay/Character/FirstPersonController.cs @@ -71,6 +71,7 @@ public class FirstPersonController: MonoBehaviour [SerializeField] private AudioClip[] stoneClips = default; [SerializeField] private AudioClip[] waterClips = default; [SerializeField] private AudioClip[] grassClips = default; + public Camera PlayerCamera => playerCamera; private float footstepTimer = 0; private float GetCurrentOffset => isCrouching ? baseStepSpeed * crouchStepMultiplier : isSprinting ? baseStepSpeed * sprintStepMultiplier : baseStepSpeed; diff --git a/Assets/Prefabs/Abilities/PF_Fireball.prefab b/Assets/Prefabs/Abilities/PF_Fireball.prefab index d5d99773..c83be557 100644 --- a/Assets/Prefabs/Abilities/PF_Fireball.prefab +++ b/Assets/Prefabs/Abilities/PF_Fireball.prefab @@ -13,7 +13,7 @@ GameObject: - component: {fileID: 4256647660557216355} - component: {fileID: 6161152517530157023} - component: {fileID: 6947929681936346855} - m_Layer: 0 + m_Layer: 7 m_Name: PF_Fireball m_TagString: Untagged m_Icon: {fileID: 0} @@ -142,10 +142,26 @@ PrefabInstance: serializedVersion: 3 m_TransformParent: {fileID: 7202875268415372754} m_Modifications: + - target: {fileID: 112572, guid: 3b671081e44be1c4aa4355e8ba6e8a5e, type: 3} + propertyPath: m_Layer + value: 7 + objectReference: {fileID: 0} + - target: {fileID: 126572, guid: 3b671081e44be1c4aa4355e8ba6e8a5e, type: 3} + propertyPath: m_Layer + value: 7 + objectReference: {fileID: 0} - target: {fileID: 147436, guid: 3b671081e44be1c4aa4355e8ba6e8a5e, type: 3} propertyPath: m_Name value: FireballMissileFire objectReference: {fileID: 0} + - target: {fileID: 147436, guid: 3b671081e44be1c4aa4355e8ba6e8a5e, type: 3} + propertyPath: m_Layer + value: 7 + objectReference: {fileID: 0} + - target: {fileID: 166048, guid: 3b671081e44be1c4aa4355e8ba6e8a5e, type: 3} + propertyPath: m_Layer + value: 7 + objectReference: {fileID: 0} - target: {fileID: 460430, guid: 3b671081e44be1c4aa4355e8ba6e8a5e, type: 3} propertyPath: m_LocalScale.x value: 2 diff --git a/Assets/Scripts/Abilities/AbilityClasses/FireballAbility.cs b/Assets/Scripts/Abilities/AbilityClasses/FireballAbility.cs index 5a84c42a..ff93954a 100644 --- a/Assets/Scripts/Abilities/AbilityClasses/FireballAbility.cs +++ b/Assets/Scripts/Abilities/AbilityClasses/FireballAbility.cs @@ -12,14 +12,50 @@ public class FireballAbility : Ability { if (!user || !projectilePrefab) return; - var go = Instantiate(projectilePrefab, user.CastPos(), Quaternion.LookRotation(user.Forward())); - var rb = go.GetComponent(); - if (rb) rb.velocity = user.Forward() * speed; + // 1) Figure out an aim direction that includes camera pitch + // Try to use an "aim camera" on the user if you have one; otherwise Camera.main. + Camera cam = null; + if (Polyart.FirstPersonController.instance) + cam = Polyart.FirstPersonController.instance.PlayerCamera; + if (!cam) cam = Camera.main; + + Vector3 castPos = user.CastPos(); + Vector3 dir = user.Forward(); // safe fallback + + if (cam) + { + // Ray from camera forward + Ray ray = new Ray(cam.transform.position, cam.transform.forward); + + // If we hit something, aim at that point; otherwise aim far away + Vector3 targetPoint; + if (Physics.Raycast(ray, out RaycastHit hit, 1000f, ~0, QueryTriggerInteraction.Ignore)) + targetPoint = hit.point; + else + targetPoint = ray.origin + ray.direction * 1000f; + + dir = (targetPoint - castPos).normalized; + } + + // 2) Spawn & orient the projectile along that 3D direction + var go = Instantiate(projectilePrefab, castPos, Quaternion.LookRotation(dir)); + + // 3) Give it velocity along the aimed direction + var rb = go.GetComponent(); + if (rb) + { + rb.velocity = dir * speed; // or: rb.AddForce(dir * speed, ForceMode.VelocityChange); + rb.useGravity = false; // optional: keep straight flight + rb.collisionDetectionMode = CollisionDetectionMode.Continuous; // nicer for fast shots + } + + // 4) Damage component (unchanged) var dmg = go.GetComponent(); if (!dmg) dmg = go.AddComponent(); dmg.damage = damage; Destroy(go, lifeTime); } + } \ No newline at end of file diff --git a/Assets/Scripts/Abilities/AbilityClasses/FreezeShardAbility.cs b/Assets/Scripts/Abilities/AbilityClasses/FreezeShardAbility.cs index 02ca5563..f921ca11 100644 --- a/Assets/Scripts/Abilities/AbilityClasses/FreezeShardAbility.cs +++ b/Assets/Scripts/Abilities/AbilityClasses/FreezeShardAbility.cs @@ -14,19 +14,47 @@ public class FreezeShardAbility : Ability { if (!user || !projectilePrefab) return; - var pos = user.CastPos() + user.Forward() * spawnOffset; - var rot = Quaternion.LookRotation(user.Forward()); - var go = Instantiate(projectilePrefab, pos, rot); + // Get player camera (from FPS controller or fallback to Camera.main) + Camera cam = null; + if (Polyart.FirstPersonController.instance) + cam = Polyart.FirstPersonController.instance.GetComponentInChildren(); + if (!cam) cam = Camera.main; + // Start slightly in front of the cast position + Vector3 castPos = user.CastPos() + user.Forward() * spawnOffset; + + // Default direction if no camera found + Vector3 dir = user.Forward(); + + if (cam) + { + // Ray from camera forward + Ray ray = new Ray(cam.transform.position, cam.transform.forward); + + Vector3 targetPoint; + if (Physics.Raycast(ray, out RaycastHit hit, 1000f, ~0, QueryTriggerInteraction.Ignore)) + targetPoint = hit.point; + else + targetPoint = ray.origin + ray.direction * 1000f; + + dir = (targetPoint - castPos).normalized; + } + + // Spawn projectile oriented to camera direction + var go = Instantiate(projectilePrefab, castPos, Quaternion.LookRotation(dir)); + + // Push it forward var rb = go.GetComponent(); - if (rb) rb.velocity = user.Forward() * speed; + if (rb) rb.velocity = dir * speed; + // Apply freeze shard properties var shard = go.GetComponent(); if (!shard) shard = go.AddComponent(); shard.damage = damage; shard.freezeDuration = freezeDuration; shard.ownerRoot = user.transform; + // Ignore collisions with the caster var projCol = go.GetComponent(); if (projCol) { @@ -36,4 +64,5 @@ public class FreezeShardAbility : Ability Destroy(go, lifeTime); } + } \ No newline at end of file diff --git a/Assets/Scripts/Abilities/AbilityUser.cs b/Assets/Scripts/Abilities/AbilityUser.cs index e288f0e5..5c0c63b8 100644 --- a/Assets/Scripts/Abilities/AbilityUser.cs +++ b/Assets/Scripts/Abilities/AbilityUser.cs @@ -25,5 +25,6 @@ public class AbilityUser : MonoBehaviour } public Vector3 Forward() => castPoint ? castPoint.forward : transform.forward; + public Vector3 Upward() => castPoint ? castPoint.up : transform.up; public Vector3 CastPos() => castPoint ? castPoint.position : transform.position; } \ No newline at end of file diff --git a/ProjectSettings/DynamicsManager.asset b/ProjectSettings/DynamicsManager.asset index fc90ab95..4299ca6d 100644 --- a/ProjectSettings/DynamicsManager.asset +++ b/ProjectSettings/DynamicsManager.asset @@ -3,10 +3,11 @@ --- !u!55 &1 PhysicsManager: m_ObjectHideFlags: 0 - serializedVersion: 13 + serializedVersion: 14 m_Gravity: {x: 0, y: -9.81, z: 0} m_DefaultMaterial: {fileID: 0} m_BounceThreshold: 2 + m_DefaultMaxDepenetrationVelocity: 10 m_SleepThreshold: 0.005 m_DefaultContactOffset: 0.01 m_DefaultSolverIterations: 6 @@ -17,10 +18,11 @@ PhysicsManager: m_ClothInterCollisionDistance: 0.1 m_ClothInterCollisionStiffness: 0.2 m_ContactsGeneration: 1 - m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff - m_AutoSimulation: 1 + m_LayerCollisionMatrix: fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + m_SimulationMode: 0 m_AutoSyncTransforms: 0 m_ReuseCollisionCallbacks: 1 + m_InvokeCollisionCallbacks: 1 m_ClothInterCollisionSettingsToggle: 0 m_ClothGravity: {x: 0, y: -9.81, z: 0} m_ContactPairsMode: 0 @@ -32,5 +34,7 @@ PhysicsManager: m_FrictionType: 0 m_EnableEnhancedDeterminism: 0 m_EnableUnifiedHeightmaps: 1 + m_ImprovedPatchFriction: 0 m_SolverType: 0 m_DefaultMaxAngularSpeed: 50 + m_FastMotionThreshold: 3.4028235e+38 diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index 7c0e16bb..3a329485 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -12,8 +12,8 @@ TagManager: - Water - UI - WalkableStreet - - - - + - Fireball + - Player - - -