lobisurvey.blogg.se

Godot raycast
Godot raycast





I'm happy to lend my hand if/where/when it's wanted. This is definitely a feature I've missed in Godot when migrating from other engines. If you think it's worth adding an entire ShapeCast2D/3D to Godot core and you feel like the described implementation is logical/fits the requirements, I can make a PR, but additional work is needed to port this to 3D. In fact, given the same logic, the existing Ra圜ast nodes can also be re-implemented via script. Some engines like Unity already provide similar functionality though, also the mentioned PhysX library. Performance is the only reason why this might be needed for core. This can be implemented via plugin/module. There's no particular reason why this should be part of the core. Is there a reason why this should be core and not an add-on in the asset library?: If this enhancement will not be used often, can it be worked around with a few lines of script?:Ĭannot be worked around with a few lines of script. the ShapeCast node's own transform can be modified to alter the shape in any way by translating, rotating and scaling.You can move the shapecast along safe distance to repeat the process from that point without the node being stuck inside the collider, for instance. get_closest_collision_safe/unsafe_distance used for querying the intersections exactly outside/inside collision.exposed collision_result as a property so that if there's a need to fetch more collision information not provided by the API by default (collider's linear_velocity, metadata etc).

godot raycast

get_closest_* methods should be used instead if you come from Ra圜ast2D. can return multiple results (the number of results is limited by max_results property for performance reasons).Can also help workaround CCD issues: Continuous CD not working godot#9071. Immediate information can be forced with force_shapecast_update. In this case, such node can be used as a general-purpose, (continuous) collision detection area which can overcome limitations of Area2D. casting can work with cast_to = Vector2().ability to configure collision margin for shapes.For 2D, CircleShape2D can be possibly instantiated by default. obviously you need to assign any Shape2D resource before using.The implementation is based on Ra圜ast2D (copy-pasted and adapted), uses PhysicsDirectSpaceState.cast_motion along with PhysicsDirectSpaceState.get_rest_info internally, so in most cases it reflects Ra圜ast2D API, with the following differences: I've managed to implement this via C++ modules in Goost, and replaced some GDScript classes already with it in my own projects. Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams: Ability to assign any existing Shape2D or Shape3D is enough for this to overcome limitations of ray casting.

godot raycast

Describe the feature / enhancement and how it helps to overcome the problem or limitation:Ĭreating ShapeCast2D and ShapeCast3D analogously to Ra圜ast2D and Ra圜ast3D nodes. Using the low-level direct space state API is the only way to fetch immediate overlap information which is robust (with or without shape sweep test), but again it's quite cumbersome to use for most users. One can use signals for that, but that mostly leads to inconveniences because you have to ensure that no duplicate bodies is detected within the signal callback, and you need to collect a list of overlapped bodies manually. It's also difficult to get collision overlaps with Area2D/3D and often requires waiting a couple of frames before collision information is available to these nodes, when immediate information is preferable. For that one needs to cast multiple ray cast in the same direction, which is a hacky thing to do. Ray casting is not as flexible or robust when it comes to detecting collision bodies along the ray cast area/volume (can easily miss objects, for example beam weapons which has a notion of width of a beam, which raycast doesn't have). Goost - Godot Engine extension Describe the problem or limitation you are having in your project:

godot raycast

See the 3D version of this proposal at #2896.







Godot raycast