Skip to content
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

games_fps Example: Collision detection anomaly #28660

Closed
Jinxishihenian opened this issue Jun 15, 2024 · 4 comments · Fixed by #28662
Closed

games_fps Example: Collision detection anomaly #28660

Jinxishihenian opened this issue Jun 15, 2024 · 4 comments · Fixed by #28662
Milestone

Comments

@Jinxishihenian
Copy link

Description

In the games_fps example, when the player is stationary, the collision detection fails almost every six seconds.

Reproduction steps

In 'https://threejs.org/examples/?q=gam#games_fps' the player stands still and the octree outputs the result of the collision.

Code

	function playerCollisions() {

		const result = worldOctree.capsuleIntersect(playerCollider);
		// When the player is stationary on the ground, it triggers almost every six seconds or so
		if (!result) {
			console.log('fail');
		}
	 
		playerOnFloor = false;

		if (result) {
	 
			playerOnFloor = result.normal.y >= 0;

			if (!playerOnFloor) {

				playerVelocity.addScaledVector(result.normal, -result.normal.dot(playerVelocity));

			}

			playerCollider.translate(result.normal.multiplyScalar(result.depth));

		}
 
	}

Live example

111

Screenshots

No response

Version

0.165.0

Device

Desktop

Browser

Chrome

OS

Windows

@Mugen87
Copy link
Collaborator

Mugen87 commented Jun 15, 2024

I'm unable to reproduce the issue with Chrome on macOS. fail is only logged at the very beginning of the app when player is still in the air. But as soon as the player is on the ground, there are no additional logs (unless you jump or fall down a platform).

Do you mind recording a short video that shows how the messages are logged in your browser?

@ycw
Copy link
Contributor

ycw commented Jun 15, 2024

It's reproducible when player idles on ramp for a while

@Mugen87
Copy link
Collaborator

Mugen87 commented Jun 15, 2024

Oh, now I can reproduce as well.

@Jinxishihenian
Copy link
Author

Very efficient efficiency, thank you very much

@Mugen87 Mugen87 added this to the r166 milestone Jun 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants