Check trajectory collision for object

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Lex4990

Hi!
In my game i need launch 2d rigid body(but considering kinematic body posible too). But before this, i need dysplay to player flight trajectory. Before landing, object can colide with walls or other objects, and trajectory can deviates, that needs to display. To calculate points of trajectory i’m use this equation: x= ut, y= (gt^2)/2. Every point counted in loop. To check collision i need i’n every loop place object to point, counted previously, and move to newly counted point. I cant find function for it. Basic functions for collision check, check moving from actual object position.
Hope someone understand me :smiley: Sorry for bad language and thanks in advance for responce!

In this case a raycast may come in handy.
See here:
Ray-casting — Godot Engine (latest) documentation in English

var space_state = get_world_2d().direct_space_state
# use global coordinates, not local to node
var result = space_state.intersect_ray(Vector2(0, 0), Vector2(50, 100))

Can’t tell if it is performance-wise the optimum solution though.

wombatstampede | 2019-02-25 14:30

But how be with collision box? If i correct, ray - it’s line and its dosn’t represent objects form.

Lex4990 | 2019-02-25 17:40