#Referencing objects outside of _PhysicsProcess apparently a no no?

6 messages · Page 1 of 1 (latest)

outer quartz
#

So I shot a ray within _PhysicsProcess:

            var spaceState = GetWorld3D().DirectSpaceState;
            var rayQ = PhysicsRayQueryParameters3D.Create(interactRayStart, interactRayEnd);
            var rayResult = spaceState.IntersectRay(rayQ);
            interactObj = rayResult["collider"] as object;

interactObj declared in a way I am pretty sure is within scope (tested this by storing the object's name as string here and tried to pass the string in similar fashion)

The minute I reference interactObj outside the loop _PhysicsProcess on a different thread (running at different rates as _PhysicsProcess), it magically dissapeares.

Seems like Godot is passing a pointer here and the pointer is only guranteed valid within that _PhysicsProcess loop, so how do you pass a object or a node outside of _PhysicsProcess so we don't do EVERYTHING in _PhysicsProcess?

timber raptor
#

You're using an actual separate thread? Or just trying to reference it from somewhere else?

outer quartz
#

Separate thread, does it matter? I can pass strings no problem. Even if the strings was set within the scope of _PhysicsProcess

timber raptor
#

I would expect this to be fine normally, but I'm not sure about separate threads

#

What do you mean by "magically disappears"? Like you get a null error?

#

Are you sure you aren't just removing that object or something?