decentraland / sdk

PM repository for SDK
Apache License 2.0
4 stars 4 forks source link

Raycast issue after repeating for a while #993

Open nearnshaw opened 10 months ago

nearnshaw commented 10 months ago

Reported by Will (wacaine) on Discord

There is a bug with raycasting on an interval using the same entity like is shown in the docs. the raycast result "RaycastResult.getOrNull(rayEntity)" stops returning a value after a while. can that be looked into? My result bogs down then just stops returning after ~10 seconds if I use an interval of 200 ms. I have to delete the entity and use a new one each time for it to work OR use the same entity with continuous:true which is less than ideal.

https://docs.decentraland.org/creator/development-guide/sdk7/raycasting/

"When possible, use a system (or the interval function in the Utils library) to run raycast queries at a regular more sparse interval, like just once a second, or every fifth of a second."

Using "@dcl/js-runtime": "7.3.23"

nearnshaw commented 10 months ago

@wacaine tagging you here, in case you have any other info that could help expand this any snippets?

wacaine commented 10 months ago

@nearnshaw https://youtu.be/JKRXabscK8g

here is a video and demo scene of the issue :)

ray-casting-broke.zip

pravusjif commented 9 months ago

I'm still working on a solution, but FYI what'w most likely happening is that when the raycat helper system detects that the raycats result is ready, it removed the raycats and the raycast result from the entity (since its raycast is not 'continuous') and if at that same scene runtime "frame" another registerRaycastWithCallback() is called, the raycast component gets attached again into the same entity, thus only sending out a putComponent instruction, so the client never received the removeComponent instruction and can't reset stuff on their end.

That's why I'm trying to solve this by using the raycast timeStamp property but it's not working out of the box...

pravusjif commented 9 months ago

Fix merged.

Will reach production with SDK version 7.3.30, meanwhile it can be used with @next

wacaine commented 9 months ago

@pravusjif @nearnshaw I just tested this with 7.3.30 and not seeing any change. I even tried adding &renderer-branch=main to my url locally. Still not working.

    "@dcl/js-runtime": "7.3.30",
    "@dcl/sdk": "^7.3.30"
pravusjif commented 7 months ago

@wacaine do you have the problem with the same scene you had shared earlier? because that scene worked fine for me after the fix.

Otherwise can you provide another snippet or scene in which you are experiencing the issue?

wacaine commented 7 months ago

@pravusjif Its the same example scene. Uploading the one CONTIUOUS_CAST = false and reusing entity which is the broke way ray-casting-broke 2.zip

https://youtu.be/8587asFEyrA

Using SDK

"@dcl/js-runtime": "7.3.39", "@dcl/sdk": "^7.3.39"

wacaine commented 7 months ago

@pravusjif i tried rotating between 3 different entities based on your initial thoughts that the frame order got messed up. Once an entity is used for a raycast it seems to get stuck somewhere and future raycasts with it do not work

wacaine commented 6 months ago

@pravusjif any update?