Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Unmanned |
Within a for loop, I:
- Create a new Transform() and give it a random origin point.
- Set my RayCast to that transform using set_global_transform.
- Print get_collision_point of the RayCast.
However, the coordinates from get_collision_point always equal the starting position of the RayCast (except for the y coordinate, which has changed to the floor where it is casting.)
Does anyone know why this could be happening?
var new_t = Transform(Vector3(1,0,0), Vector3(0,1,0), Vector3(0,0,1), Vector3(randi() % 100,50,randi() % 100))
$RayCast.set_global_transform(new_t)
print($RayCast.get_collision_point())
It is difficult to reproduce your error without a test scene to debug.
That being said it seems that your Raycast has an origin but does not cast_to any particular vector.
I’ve found success in this method of using Raycasting:
$RayCast.translation = new_t.origin
$RayCast.cast_to = *SomeVector3*
$RayCast.force_raycast_update()
print($RayCast.get_collision_point())
RedSlimeSkirt | 2019-11-12 14:34