Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8035751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:24:07+00:00 2026-06-05T02:24:07+00:00

I’m making a 3D game, and I was told here and here that I

  • 0

I’m making a 3D game, and I was told here and here that I should always perform collision detection on the server-side. Now, the problem is that I don’t know how! Collision between players on a flat plane are easy, because players are represented by a cylinder, but, how do I do collision detection when the map itself is a model with hills and so on? Is is possible to somehow import a 3D model on a Node.js server? And then, say I do have the model imported, are there some collision detection libraries, or will I have to do the math myself? (My last resort would be converting the models to JSON (models are already converted to JSON) and then reading in all the vertices, but that would be a pain.)

The models are made in Blender and can be converted to .obj, .dae or .js (JSON) (this is what I currently use).

If there are no such modules, that allow the models to be imported and collisions to be checked against them, I guess I could make it myself. In that case, please do provide some hints, or further reading on how to test if a point is colliding with an object defined by some vertices.

EDIT: The “map” will have objects on it, like trees and houses. I was thinking, maybe even caves. It will also have hills and what-not, but a heightmap is out of the question I guess.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T02:24:09+00:00Added an answer on June 5, 2026 at 2:24 am

    If you’re going for a do-it-yourself solution, I’d suggest the following.

    Terrain

    Preferably have the terrain be a grid, with just each vertex varying in height. The result is a bunch of quads, each with the same dimensions in the (x, y) plane. Vertices have varying (z) values to make up the slopes. The grid arrangement allows you to easily determine which triangles you will have to test for intersection when performing collision checks.

    If that’s not an option (terrain pre-built in modeling package), you’ll probably want to use an in-memory grid anyway, and store a list of triangles that are (partially) inside each cell.

    Checking for collision

    The easiest approach would be to consider your actors points in space. Then you’d determine the height of the terrain at that point as follows:

    1. Determine grid cell the point is in
    2. Get triangles associated with cell
    3. Get the triangle containing the point (in the (x, y) plane)
    4. Get height of triangle/plane at point

    In the case of the “pure grid” terrain, step 3 involves just a single point/plane check to determine which of the 2 triangles we need. Otherwise, you’d have to do a point-in-triangle check for each triangle (you can probably re-use point/plane checks or use BSP for further optimization).

    Step 4 pseudo-code:

    point = [ x, y, z ] // actor position
    
    relativePt = point - triangle.vertices[0]
    normal = triangle.plane.normal
    distance = relativePt DOT normal // (this is a dot-product)
    
    intersection = [
        point.x,
        point.y,
        point.z + distance / normal.z ]
    

    This calculates the intersection of the ray straight up/down from the actor position with the triangle’s plane. So that’s the height of the terrain at that (x, y) position. Then you can simply check if the actor’s position is below that height, and if so, set its z-coordinate to the terrain height.

    Objects (houses, trees, … )

    Give each object 1 or more convex collision volumes that together roughly correspond to its actual shape (see this page on UDN to see how the Unreal Engine works with collision hulls for objects).

    You will have to use some spatial subdivision technique to quickly determine which of all world objects to check for collision when moving an actor. If most movement is in 2 dimensions (for example, just terrain and some houses), you could use a simple grid or a quadtree (which is like a grid with further subdivisions). A 3-dimensional option would be the octree.

    The point of the spatial subdivision is the same as with the terrain organized as a grid: To associate place objects with cells/volumes in space so you can determine the set of objects to check for a collision, instead of checking for collision with all objects.

    Checking for collision

    1. Get the “potential collision objects” using the spatial subdivision technique you’ve used; f.e. get the objects in the actor’s current grid cell.
    2. For each convex collision volume of each object:
    3. Using the separating axis theorem, determine if the actor intersects with the collision volume. See my answer to a different post for some implementation hints (that question is about the 2D case, but the code largely applies; just read “edge” as “plane”).
    4. If collision occurs, use the normal of one of the “offending planes” to move the actor to just next to that plane.

    Note: In this case, model your actor’s collision volume as a box or 3-sided cylinder or so.

    Also, you may want to consider building a BSP tree for each object and use axis-aligned bounding boxes for your actors instead. But that’s getting a little beyond the scope of this answer. If your objects will have more complicated collision volumes, that will be faster.

    Final thoughts

    Well, this is already a really long answer, and these are just some broad strokes. Collision is a pretty broad topic, because there are so many different approaches you can take depending on your needs.

    For example, I haven’t covered “trace collision”, which is detecting collision when an actor moves. Instead, the above suggestion on objects checks if an actor is inside an object. This may or may not suit your needs.

    I also just realized I haven’t covered actor-vs-actor collision. Perhaps that’s best done as colliding 2 circles in the (x, y) plane, with an additional check to see if their vertical spaces intersect.

    Anyway, I really gotta wrap this up. Hopefully this will at least point you in the right direction.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.