# RayCast Collision Still Detects Standing Position After Lying Down Animation

**URL:** https://forum.castle-engine.io/t/raycast-collision-still-detects-standing-position-after-lying-down-animation/1677
**Category:** Physics and Collisions
**Created:** [February 10, 2025, 9:09pm UTC](https://forum.castle-engine.io/t/raycast-collision-still-detects-standing-position-after-lying-down-animation/1677 "2025-02-10T21:09:31Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![hal09](https://forum.castle-engine.io/letter_avatar_proxy/v4/letter/h/e9c0ed/32.png) [@hal09](https://forum.castle-engine.io/u/hal09)
#### Post date: [March 8, 2025, 10:21pm UTC](https://forum.castle-engine.io/t/raycast-collision-still-detects-standing-position-after-lying-down-animation/1677/6 "2025-03-08T22:21:42Z")

</div>

After many attempts, I reached this conclusion.

### \*\*🔹 Optimal Collision Detection Method for a Shooter Game

After extensive testing and analysis, I have found an **efficient and optimized** way to handle collision detection in a shooter game.

### **✅ Final Conclusion: The Best Collision Detection Approach**

1️⃣ **Use TCastleScene for Each Player Bone** ✅

- Every **bone** should have its own **scene without a collider (MeshCollider) or RigidBody**.
- This ensures that every part of the player’s body can be targeted accurately.

2️⃣ **Use RayCast Instead of Traditional Physics Colliders** ✅

- **RayCast can detect collisions accurately without updating the mesh collider**.
- When a bullet is fired, a **RayCast is sent from the bullet** to check for collisions with the player’s bones.
- This method ensures **real-time, accurate hit detection** , even when the player is crouching, prone, or moving dynamically.

3️⃣ **Avoid Using MeshCollider or RigidBody for the Main Player** ✅

- **MeshCollider is very CPU-intensive** because it requires continuous updates during animations.
- **RigidBody and Physics Colliders should only be used for static objects** like _ **buildings, walls, and roads** _.

4️⃣ **Use Physics RayCast Only for Static Objects** ✅

- When detecting collisions with **the environment, buildings, terrain** , **Physics RayCast is useful**.
- **For moving players, use traditional RayCast instead** to ensure real-time accuracy.

* * *

### **🎯 Key Advantages of This Method:**

✔ **Reduces CPU Load** → No need to constantly update Mesh Colliders.  
✔ **Increases Collision Accuracy** → Every body part can be hit precisely.  
✔ **Avoids Issues with Player Animation (Crouching, Prone, etc.)**.  
✔ **Easier to Implement Bullet Penetration & Damage Calculation**.

* * *

### **💡 Final Takeaway:**

**✅ Use RayCast with bone-based scenes (without physical colliders) for player hit detection, and use Physics RayCast only for static objects like buildings and terrain.**

🚀 **This method provides the best performance and accuracy for modern shooter games!**

---

_[View the full topic](https://forum.castle-engine.io/t/raycast-collision-still-detects-standing-position-after-lying-down-animation/1677)._
