opened 02:41PM - 08 Mar 25 UTC
bug
**Describe the bug (REQUIRED)**
Using physics.raycast() sometimes causes a crash….
**To Reproduce (REQUIRED)**
This code:
```
local from = vmath.vector3(0, -13200000, 0)
local to = from + vmath.vector3(0, -1, 0)
local groups = {hash("test")}
physics.raycast(from, to, groups)
```
Together with the game.project setting:
```
[physics]
scale = 0.01
```
Causes a crash with this message:
`Assertion failed: (r.LengthSquared() > 0.0f), function RayCast, file b2DynamicTree.h, line 232.`
**Expected behavior (REQUIRED)**
Usually when a ray’s vector has 0 length, this warning is displayed instead:
`WARNING:PHYSICS: Ray had 0 length when ray casting, ignoring request.`
It could have something to do with floating point precision, because of the extreme numbers, coupled with a short ray.
The crash can be avoided, but it may be better to catch it and display the above message instead?
**Defold version (REQUIRED):**
1.9.7
**Platforms (REQUIRED):**
macOS Sonoma (14.6.1)
**Minimal repro case project (OPTIONAL):**
[RaycastCrash.zip](https://github.com/user-attachments/files/19144151/RaycastCrash.zip)
**Workaround (OPTIONAL):**
Avoid using raycasts for extreme numbers.
**Additional context (OPTIONAL):**
https://forum.defold.com/t/raycast-crash/79990