-
-
Notifications
You must be signed in to change notification settings - Fork 325
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
Using more than one boxcast in a single update breaks some of the boxcasts. #665
Comments
I think I've narrowed down the issue to 2 things. Firstly, if you look at the boxcast function, you'll see that it reuses the same _boxcast_box variable to measure all its collisions. This is done for optimization reasons, there is, however, a problem here. There are some properties, I think something to do with the look_at function, that persist between boxcast calls. This makes it so that subsequent calls are affected by previous ones. In the boxcasts function, I changed line 24 from There is also a broader issue, that has to do with coding standards. The issue is that the boxcast function isn't pure, which is a problem if it's a static function. I would suggest 2 approaches to fixing this from a best practices point of view. The first would to be just simply make boxcast a class, and then create an instance for ray you want to cast, and have the memory be properly managed within the class. The second would be to have the boxcast function recreate the _boxcast_box variable inside its function scope each time, and give the programmer the option to pass in their own _boxcast_box variable, that is reused, if they wished to save memory. |
I think there might be some unforeseen consequences when calling the boxcast function Lines 23 to 25 in c587be2
In the function, it then uses the entities up, instead of a passed in up Lines 943 to 946 in c587be2
|
I am busy rewriting ursina.prefabs.platformer_controller_2d
In the update function, you can see it uses boxcast 3 times (the last time doesn't matter as much) .
ursina/ursina/prefabs/platformer_controller_2d.py
Line 80 in c587be2
I've refactored it to this, we have a boxcast for the sides, and we have a boxcast for the bottom.
As you can see, the debug is true. However, it will only show one at a time, depending on which one I instantiate last (it takes preference to the last one).
There's also weird behavior with the bottom cast when the vertical cast is in, even though they are unrelated. I'm linking a video to explain.
Screen.Recording.-.Made.with.FlexClip.online-video-cutter.com.webm
In this video, you can see that it does this weird thing where it bounces up and down, when I comment the boxcast that has to do with the sides (not the bottom), it then stops doing it. Also, as you can see, it only shows one debug indicator at a time.
I'm using vscode on windows.
The text was updated successfully, but these errors were encountered: