Bug fixes

This commit is contained in:
Hazim Bin Ijaz 2025-08-29 23:25:00 +05:00
parent 07626aa550
commit 7bec58ece8
8 changed files with 111 additions and 14 deletions

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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<Rigidbody>();
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<Rigidbody>();
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<ProjectileDamage>();
if (!dmg) dmg = go.AddComponent<ProjectileDamage>();
dmg.damage = damage;
Destroy(go, lifeTime);
}
}

View File

@ -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<Camera>();
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<Rigidbody>();
if (rb) rb.velocity = user.Forward() * speed;
if (rb) rb.velocity = dir * speed;
// Apply freeze shard properties
var shard = go.GetComponent<FreezeShardProjectile>();
if (!shard) shard = go.AddComponent<FreezeShardProjectile>();
shard.damage = damage;
shard.freezeDuration = freezeDuration;
shard.ownerRoot = user.transform;
// Ignore collisions with the caster
var projCol = go.GetComponent<Collider>();
if (projCol)
{
@ -36,4 +64,5 @@ public class FreezeShardAbility : Ability
Destroy(go, lifeTime);
}
}

View File

@ -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;
}

View File

@ -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

View File

@ -12,8 +12,8 @@ TagManager:
- Water
- UI
- WalkableStreet
-
-
- Fireball
- Player
-
-
-