Scarabol / rock-raiders-web

Follow the link to play in your browser
https://scarabol.github.io/rock-raiders-web/
11 stars 1 forks source link

Bugged out vehicles #5

Closed JannikHv closed 9 months ago

JannikHv commented 9 months ago

In most of the missions I play I encounter a problem, where a vehicle – for example the "small transport truck" – just bugs out at the tool store. I cannot move the vehicle anymore, can't get the rock raider out of it and also can't teleport the vehicle back. For the rest of the mission the vehicle is just standing there. Getting rid of the tool store doesn't solve the problem.

When this problem happens, I get an error message in the console:

Screenshot 2024-01-10 at 09 31 57

This error message also reappears when trying to teleport the vehicle or getting the rock raiders out of it.

This problem curred on the master branch at this commit: https://github.com/Scarabol/rock-raiders-web/commit/3f0c21f4f387949160b3baf90921be9e9d8f7baa

On the version on your GitHub Pages this also happens though.

JannikHv commented 9 months ago

I just saw that this might be a known issue, reading the README.

JannikHv commented 9 months ago

I think an additional if-check makes the issue go away:

    setPosition(position: Vector3) {
        this.sceneEntity.position.copy(position)
        const surface = this.worldMgr.sceneMgr.terrain.getSurfaceFromWorld(position)
        this.sceneEntity.visible = surface.discovered
        const components = this.worldMgr.ecs.getComponents(this.entity)

        if (components) {
            const positionComponent = components.get(PositionComponent)
            if (positionComponent) {
                positionComponent.position.copy(position)
                positionComponent.surface = surface
                positionComponent.markDirty()
                this.sceneEntity.position.y += positionComponent.floorOffset
            }
        }
    }

(MaterialEntity.ts)

At least the vehicles don't seem to bug out anymore wit the changed method above.

Scarabol commented 9 months ago

Unfortunately I could not reproduce this issue.

According to stacktrace it might happen, when a vehicle drops a material item (crystal, ore, ...) for the second time or if any other action previously removed the material entity from the game.

If this issue occurs again, please try to collect more information on which steps are necessary to reproduce this and provide them here.

Scarabol commented 9 months ago

I think your suggested fix is suitable for this case and added it in form of a ?-operator.

Thanks again!