[SOLVED] RayCast2D rotating

trafeltrafel Posts: 3Member
edited June 2016 in 2D
Hi, I was wondering if there was an easier way of disabling the raycast rotation without having to mess with its rotation matrix.<br /><br />I have a ball that rolls in a flat ground with a raycast attached to it that tells me if the ball touches the ground.<br /><br />EDIT :<br /><br />After messing with the matrix, I figured out how to transform the object without rotating it based on the ball's matrix. I changed the parent of the raycast to be the top node2d (World). But I think its now making problems with the display or something. the raycast has exactly the same coordinates as the ball, but it's sprite just wont show. Maybe it's changing the value of its z-index ?<br /><br />Here is the code :<br /><br />
ray_origin = get_transform().get_origin()<br />ray_scale = get_transform().get_scale()<br />ray_rotation = Vector2(0, 0)<br />raycast_down.set_transform(Matrix32(ray_scale, ray_rotation, ray_origin))<br />print(raycast_down.get_transform())
<br /><br />EDIT2 :<br /><br />The output tells me that the raycast doesnt collide no matter how rotated the ball is. So the transformation matrix returned is wrong ?<br /><br />EDIT3 :<br /><br />I think it really is a display bug since the camera I've attached to the raycast follows the ball. But the fact that the is_colliding() function doesn’t return true confuses me.<br /><br />SOLUTION :<br /><br />I finally found the solution. It was easier than I though. It is actually possible to access the raycast rotation properties directly in its object. So in the fixed process loop I just had to execute this code :<br /><br />
<br /><br />And voila !


Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file