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

feat: make gravity scale a vector to change gravity direction at runtime #40

Closed
amyspark-ng opened this issue May 23, 2024 · 3 comments
Closed
Labels
enhancement New feature or request

Comments

@amyspark-ng
Copy link
Contributor

Would it be possible to implement a system where the gravity for body() components changes direction at runtime? (replit/kaboom#575)

Was in the original kaboom issues tab, thought it was still relevant, so it might be a nice feature

Originally posted by @amyspark-ng in #39

@amyspark-ng amyspark-ng changed the title > Would it be possible to implement a system where the gravity for body() components changes direction at runtime? (https://github.com/replit/kaboom/issues/575) feat: make gravity scale a vector to change gravity direction at runtime May 23, 2024
@mflerackers mflerackers added the enhancement New feature or request label May 25, 2024
@amyspark-ng
Copy link
Contributor Author

isGrounded() won't work if the gravity is negative #689
replit/kaboom#689

i don't know if this was fixed but might still be relevant

Also got me thinking on maybe creating a different function for body component called addForce, where it's like jump, but you can also set horizontal force applied?

@mflerackers
Copy link
Member

I'll add it once I refactor gravity. I'll add applyForce and applyImpulse.

@mflerackers
Copy link
Member

Right now there are tests like

isFalling(): boolean {
  return this.vel.y > 0
},

isJumping(): boolean {
  return this.vel.y < 0
},

These need to become

isFalling(): boolean {
  return this.vel.dot(gravity) > 0 // Same direction as gravity
},

isJumping(): boolean {
  return this.vel.dot(gravity) < 0 // Opposite direction as gravity
},

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