-
-
Notifications
You must be signed in to change notification settings - Fork 978
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
Bepu Physics - Raycast does not intercept Entity with BodyComponent #2649
Comments
Hmm, check my examples, I also move the sphere (maybe my sphere is not kinematic) but seems to be working.. |
@VaclavElias I see in your examples that you move BodyComponent by setting Also, setting Is it possible that the issue manifests only when directly positioning the entity? |
It should work also your way, but we just need to figure out how to do it. The other thing in my mind is |
Oh yeaaah!! That was it! ✔Setting ❌If I set Awake = true in |
Not sure, we need to learn also how to use Can I use some of your code in our toolkit examples? |
Offcourse, it would be a pleasure to contribute someway! I updated my repo to include in debug output the value of
No, this does not happen. If I dont set |
@luca-domenichini could you try #2650 - I used the repro you provided and it seems to work |
Just a note, setting the position property itself is not really moving the object, it is teleporting it, the distinction is important as it disregards any obstacle that might be in the way. stride/sources/engine/Stride.BepuPhysics/Stride.BepuPhysics/BodyComponent.cs Lines 214 to 223 in 2080823
If you're manipulating the position every frame, that's a good indicator that you should be using linear velocity instead. |
I have been using "teleporting" because I know the final position I want to reach, so "lerping" the position every frame seemed to me the obvious way-to-go. |
Release Type: Official Release 4.2.0.2293
Platform(s): Windows
Describe the bug
I have a sample project where I have 2 spheres, using Bepu Physics.
The first one, on the right with gray metal material, has a
StaticComponent
and a Sphere Collider.The second one, on the left with golden metal material, has a
BodyComponent
flagged asKinematic
and a Sphere Collider as well.I tweaked the default
BasicCameraController.cs
created by default Game Studio to add a raycast in order to display the hovering entity by usingDebugText.Print()
method.✔When hovering on the "Static" sphere, even when it is moved away from its initial position, is working well.
❌When hovering on the "Body" sphere, raycasting returns that entity only when the sphere is in its initial position. If the user left clicks on the screen, the sphere moves to that point and raycasting stops working.
Default initial position:
After moving "Body" sphere away from initial position raycast does not intercept the sphere anymore ("hovering on Ground" tells me that):
If I return the sphere back to origin, raycast starts working ok again.
Raycasting on "Static" sphere always works ok.
To Reproduce
Clone repro repo here https://github.com/luca-domenichini/StrideRaycastIssueRepro
My doubt is that, maybe, I am not moving the "body sphere" the right way.
To move that sphere I am using a
MoverScript
attached toGround
entity.In that script I set
BodyComponent::Position
property instead of the usualEntity.Transform.Position
.This is the line of code where "lerping" the position:
https://github.com/luca-domenichini/StrideRaycastIssueRepro/blob/bcf1c70ceb8cf1ace3fc30bc0fbd856b9765bc38/StrideRaycastIssue/MoverScript.cs#L73
Expected behavior
Raycast should work fine on moved BodyComponent entities.
Additional context
I also tried to move the sphere by setting
Entity.Transform.Position
, but that seems to be worse since the Entity is moving but position of the BodyComponent stands still at (0, 0.5, 1) insted of following the Entity.. but maybe I am missing something..The text was updated successfully, but these errors were encountered: