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

Surfing System #31

Open
Zrocket opened this issue Dec 27, 2023 · 7 comments
Open

Surfing System #31

Zrocket opened this issue Dec 27, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@Zrocket
Copy link
Contributor

Zrocket commented Dec 27, 2023

I decided to create a new issue to discuss how to properly implement surfing. I created a modified version of the example map to test with. Furthermore, I've found that using 30 to 40 percent of the add.x and add.z velocity gets us somewhat close to the desired effects, but there are still some issues. I'll have to look further into how surfing works in the original source engine, and how others have simulated it.

@Zrocket
Copy link
Contributor Author

Zrocket commented Jan 1, 2024

I think I've made some progress, albeit very minor. According to what I can find documenting the Quake and Source engines, I added a check in the acceleration function to return a zero vector if the result is greater than max_air_speed. This seems to result in slightly better surf physics, in that holding W will make you lose velocity, while only strafing will increase it. However, I'm still having issues debugging why you can still accelerate directly up the slope by strafing into it. From what I've found documenting the physics mathematics of half-life, there's some calculation related to the surface normal that should be modifying and slowing the player velocity, but I've yet to properly recreate it.

@Zrocket
Copy link
Contributor Author

Zrocket commented Jan 1, 2024

@qhdwight
Copy link
Owner

qhdwight commented Jan 2, 2024

Nice, feel free to open a PR when ready. Can even be a draft for now.

@Zrocket
Copy link
Contributor Author

Zrocket commented Jan 3, 2024

Alright. I'll push what I've gotten working for now.

@qhdwight qhdwight added the enhancement New feature or request label Jan 7, 2024
@Zrocket
Copy link
Contributor Author

Zrocket commented Jan 12, 2024

I'm still studying the physics math of Half-Life, but I found this interesting formula for calculating the general collision equation for entities with a surface:

$v'=v-b(Cb,Ke)(v \cdotp \hat{n})\hat{n}$

Where:
$v'$ is the new velocity
$v$ is the current velocity
$b(Cb,Ke)$ is the function for the bounce coefficient (apparently this usually results to 1 with the player entity)
$\hat{n}$ is the plane normal of the colliding surface

But from what I can tell, this is already implemented in the controller code. However, the bounce coefficient is missing, which we can implement for cases where the player needs a bounce value other than 1, or if the user wishes to change the value of sv_bounce.

@Zrocket
Copy link
Contributor Author

Zrocket commented Jan 13, 2024

Another piece of interest, is that there's a few different entity movement types we could theoretically implement However, I'm not sure if they're in scope for this project, as to my understanding we're only focusing on the player entity:

https://www.jwchong.com/hl/entity.html#movement

Maybe I'll eventually make a fork for other entities. I don't know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants