Skip to main content

User login

What is OpenID?
  • Log in using OpenID
  • Cancel OpenID login
  • Create new account
  • Request new password
Register
  • Home
  • Browse
    • 2D Art
    • 3D Art
    • Concept Art
    • Textures
    • Music
    • Sound Effects
    • Documents
    • Featured Tutorials
  • Submit Art
  • Collect
    • My Collections
    • Art Collections
  • Forums
  • FAQ
  • Leaderboards
    • All Time
      • Total Points
      • Comments
      • Favorites (All)
      • Favorites (2D)
      • Favorites (3D)
      • Favorites (Concept Art)
      • Favorites (Music)
      • Favorites (Sound)
      • Favorites (Textures)
    • Weekly
      • Total Points
      • Comments
      • Favorites (All)
      • Favorites (2D)
      • Favorites (3D)
      • Favorites (Concept Art)
      • Favorites (Music)
      • Favorites (Sound)
      • Favorites (Textures)
  • ❤ Donate
Programming

best way to write physics,detection in games

ǝıuusןısn
Friday, August 2, 2019 - 03:13

especially games that can wallrun, slide along edges, one that especially do not cause clip in or  fallthrough floors,

and maybe efficient byte sizes? maybe like this...

https://www.youtube.com/watch?v=xwcM_7yMygc

 

or this, where it detects wall without facing it.

https://www.youtube.com/watch?v=X3bxZnvQ1AE

 

help?

  • Log in or register to post comments
Thulium Studios
joined 10 years 1 week ago
Saturday, August 3, 2019 - 07:40
Thulium Studios's picture

Let me preface by saying there are several ways to go about physics like this, and many cases are going to require their own unique implementation.

If you don't absolutely HAVE to write your physics engine from scratch, I would highly advise an engine such as Bullet physics, depending on your language. I know Bullet has ports to C++, Java, Python, and JavaScript, and I wouldn't doubt if there were more. I use Bullet on my 3D java projects and it is an incredibly powerful tool.

Now, as for the specific methods of achieving what you posted for wall running, a few potential options could be:

  • Continuously apply a force to the object's body of (0, SPEED * GRAVITY, 0) large enough to counteract the 'GRAVITY' constant. To keep the player on place, you'd also have to lock the X and Z in place
  • Hard set the body's velocity to (0, SPEED, 0)
  • With a defined line life the aforementioned edges you posted, you could interpolate the body's position to interpolate from the starting position to the ending position over a time of the player's speed divided by the distance

 

  • Log in or register to post comments
nublet
joined 6 years 2 months ago
Sunday, August 4, 2019 - 02:36
nublet's picture

An alternative is to have different movement functions for your character (e.g. walking, freefall, in water, climbing a ladder, wallrun, etc.) that are called each frame by a master function that checks whether the character is on the ground, hugging a wall, and so on, where the standard gravity applies only in some of these functions. The old Quake 3 Arena used to work this way; its collision detection is very robust - no objects clip through walls, no matter how small and fast, and, if you're working with a simpler engine or want to code the physics/collision detection from scratch it may be of inspiration.

  • Log in or register to post comments