Closed firebelley closed 6 years ago
When Godot crashes it should print a backtrace to the console; I would believe that's true of the mono flavor as well. What does that say?
I'm not setup with mono, but I ported your ErrorDemo.cs to GDScript.
extends Node2D
func _unhandled_input(event):
if event.is_pressed():
doIntersect()
func doIntersect():
var space = get_world_2d().get_direct_space_state()
print(space)
var from = global_position
var to = global_position + Vector2(100, 0)
var result = space.intersect_ray(from, to, [], 1)
print(result)
Clicking produces the following results:
[Physics2DDirectSpaceStateSW:945]
(collider:[StaticBody2D:959]), (collider_id:959), (metadata:Null), (normal:(-1, 0)), (position:(243.863998, 70.263199)), (rid:[RID]), (shape:0)
Note that GDScript complained about passing null
to intersect_ray()
; an empty array allowed me to continue. You might want to try that in C# too.
Thanks for the suggestion, unfortunately changing the relevant line to:
var result = space.IntersectRay(from, to, new object[0], 1);
Still causes a crash
This is true even in 3d. (Beta 2 Mono)
CC @neikeq
The error I am getting is the same with this issue : https://github.com/godotengine/godot/issues/13090 But I tracked down the problem and I get it only when I use IntersectRay By the way I am getting the state by using
GetWorld().GetDirectSpaceState().IntersectRay(rayFrom, rayTo, new object[] {});
Godot version: 3.0 beta 2 (with mono)
OS/device including version: Windows 10 Version 10.0.16299 build 16299
Issue description: Trying to query the 2D physics space for ray intersections causes the program to crash.
Steps to reproduce: Run the provided minimal reproduction project. Click the screen and observe the crash. Code is in
ErrorDemo.cs
Minimal reproduction project: Error.zip