I dont understand rays. Please explain this.
Just be clear and understandable. Please respond fast bc i need to finish my project before (Thursday) 7 PM.
I dont understand rays. Please explain this.
Just be clear and understandable. Please respond fast bc i need to finish my project before (Thursday) 7 PM.
Object to test against the ray : select an object that you want to hit by the ray.
In the example it is a group called Solid that include the player object and the walls because you don’t want the ray to pass the wall and you want to look specifically for the player in the example if visible or not. If hit by the ray, it is visible.
Source X : the X position where you want to cast the ray from
Source Y: the Y position where you want to cast the ray from.
In the example it is the tanks.
Ray Angle : basically the direction where do you want to cast the ray to
In the example we want to cast the ray from the tanks to the player. At the time there was no action to cast ray to position so this math expression was used to calculate the angle from 2 point. But you can use Raycast to position now instead.
Ray maximum distance : you don’t want a ray to go forever, how far do you want it to go from the start position… In the example it is 600 pixels.
Variable to store position of the intersection : when the ray hit something, it is going to store the X and Y position of the hit that you can use later if you want to know where the hit happened exactly.
Then, you need to use a sub event and in the sub event you need to use the condition to check how many solid was picked by the ray, in this case the player (the player is member of the solid group). If the number picked is > 0 then the tank see the player because the player was picked.
I believe this is the only event in GDevelop that require a sub-event specifically so it is not as flexible as the other events in GD and a bit unusual. You must look for the objects picked by the ray in a sub-event as demonstrated in the example and you need to setup the raycast as I have explained above.
When you need help about events, you can see on your screen at bottom center, a button called
“HELP FOR THIS CONDITION”
@Bouh actually “Help for this condition” (for the 2 raycast conditions) lead to a moved page:
https://wiki.gdevelop.io/gdevelop5/objects/base_object/events?utm_source=gdevelop&utm_medium=help-link
The link to follow brings here, where no info about raycast can be found: Objects [GDevelop wiki]
The only documentaiton on the wiki about raycast is on this page and is really poor.
I hope this report might help
I’m upping this post because i’m trying to document an issue, probably a bug, i encounter with raycast
There is indeed no documentation for the raycast on the wiki
what is the name of the second condition i cant find it?, the one to check what it colided with
It’s best not to reply to old posts especially if they’re marked solved. It’s better to start a new post and reference the other post. People don’t always read a post if it’s marked solved.
GD has changed a lot in the last few years. I’m not sure which event you’re referring to but it could’ve been renamed or depreciated since then.
It looks like the ray cast might have picked multiple objects at one time. At least that’s how I read it. Currently, ray casting only picks the closest object unless inverted then it picks the farthest object.
If that doesn’t answer your question, you’d get a quicker reply by starting a new post.