-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RayCast2D behaves erratically if a lot of exceptions are added #37736
Comments
Hi, thanks for looking. The green block on the red line should stay a constant distance from the right most side which is where the raycasts are coming from. When I run the project, the raycast will not detect any new blocks that are placed for a random amount of time. I have included a gif that hopefully can explain it better than I can. You did give an idea though. I will run it on my Ubuntu machine and report back |
I ran the project on my Linux machine and while the problem is still there, it does not seem nearly as bad. I think i have discovered though, that is has something to do with adding exceptions to the raycast in gdscript. If the raycast hits an object that was not created by its parent, (In this project case, if it hits a blue block instead of a red one) it will add an exception and do a force_raycast_update. I have confirmed that it is not adding any red blocks to the exceptions list. |
It is definitely raycast exceptions. I have made a much simpler project demonstrating the issue I am having. Behold: The top line is being drawn and added to the bottom line's raycast exceptions. The bottom line does the same as it did before; raycasts to the left, the block it hits changes color to green and then it moves to the right. The green block should always appear to be 2 blocks away from the right most block. |
I found that if i clear the raycast exceptions and do a force_raycast_update at the beginning of _physics_process, then i get the expected behaviour. Is there a limit or some quantity of exceptions that would cause a raycast to behave as depicted above? I will wait to hear from someone before I close this issue in case it actually is an issue that needs correcting. |
The problem is the |
Closing as fixed on master with 4f16397. This ensures that RIDs are compared using their ID not the pointer to the underlying data, which can be reallocated when freed. |
That is a very good explanation. Thankyou for looking into it. |
Godot version:
3.2.1.stable
OS/device including version:
Windows 10 64-bit
Issue description:
I have an instanced object moving to the right with 2 raycasts attached as children. One pointing left and one pointing down. They are both enabled and set to detect Areas. As it moves right, it places a "tail_segment" (think of the game snake) in its previous location with an Area2D attached. There are other instances of this object that are spawned in front of the primary object and move upwards. They have the same action of placing "tail segments" behind them as they move. After about 15-20 seconds, the raycast that is pointing left on the primary object will start missing the segments i am placing. The first object hit by the raycast that is a tail of the primary should turn green. It slowly gets worse the longer the project is run.
Steps to reproduce:
Run the project and watch the raycast detect objects to the left of the primary object. The problem does not occur if no objects are spawned over time by setting can_spawn = false in Environment.gd. Pressing Enter can toggle spawning while project is running
Minimal reproduction project:
raycast_issue.zip
The text was updated successfully, but these errors were encountered: