# 3D[RESOLVED] Adding centers of gravity to 3D GMS2

#### E.M.I

##### Member
Hey there! After working on 2D projects for about a year I've decided to try out 3D in GMS2. For now I'm focusing on player movement and the visual style, but I know the game is going to involve jumping between small planetoids with their own centers of gravity, and I have no idea how that would work in 3D. I've also looked online but haven't been able to find anything of much help. If possible, I want to get this sorted out before I start working on it so I don't get stuck, as I'm trying to finish this game in 2 months tops. Could anyone explain to me how gravity that isn't just "gravity force is x which is always substracted from your y position if you're not colliding with the floor" would work in 3D and how it could be implemented with multiple planetoids? Thanks a lot!

#### FrostyCat

##### Member
First, learn what vector addition/subtraction, vector scaling, vector norms, matrix products, dot products and cross products are. You cannot possibly understand what others are talking about in the realm of 3D graphics if you don't speak linear algebra.

Once your vector math is in place, most of the resources you've written off would make sense to you. You would realize that gravity is simply adding a small part of the vector from your player to the gravity source (scaled by the inverse square of the distance), to the player's current velocity vector, every step. You would also begin to understand formulas for point-plane, point-sphere, ray-plane and ray-sphere collisions, which allow you to determine if you've landed on something.

Quite frankly, if you have to ask questions this basic, finishing a presentable 3D game in 2 months is a pipe dream. Give it more time, or bump it down to something your level.

#### E.M.I

##### Member
First, learn what vector addition/subtraction, vector scaling, vector norms, matrix products, dot products and cross products are. You cannot possibly understand what others are talking about in the realm of 3D graphics if you don't speak linear algebra.

Once your vector math is in place, most of the resources you've written off would make sense to you. You would realize that gravity is simply adding a small part of the vector from your player to the gravity source (scaled by the inverse square of the distance), to the player's current velocity vector, every step. You would also begin to understand formulas for point-plane, point-sphere, ray-plane and ray-sphere collisions, which allow you to determine if you've landed on something.

Quite frankly, if you have to ask questions this basic, finishing a presentable 3D game in 2 months is a pipe dream. Give it more time, or bump it down to something your level.
I'll try to study up on vector math! Maybe it's not enough time, but I have a lot of extra time on my hands and the project isn't very big anyways. Ain't a big deal if I don't finish it on time though! Thanks a lot for the response!

#### TheSnidr

##### Heavy metal viking dentist
GMC Elder
I see you've marked the topic as resolved. FrostyCat's suggestions are on point, vector math, and to a lesser degree matrix math, are essential for something like this.
I don't have much more to add, other than that I've been where you are! Here's a video of an old project of mine, in case it might be of interest to you. I made this without even knowing what a matrix was.

#### E.M.I

##### Member
I see you've marked the topic as resolved. FrostyCat's suggestions are on point, vector math, and to a lesser degree matrix math, are essential for something like this.
I don't have much more to add, other than that I've been where you are! Here's a video of an old project of mine, in case it might be of interest to you. I made this without even knowing what a matrix was.
Oh yeah, that's pretty much the kind of system I'd like to make! Hopefully I can make something similar c: