Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Mathematics questions deal with the arithmetic, geometry, calculus, formulae and other calculations used in the development of a game.

-1
votes
0answers
17 views

Server side and client side movement sync correct movement calculation

That is a 2D game, main player is in center, further the mouse cursor from center of the screen(from the player) higher is his acceleration, also player is moving in the direction of mouse cursor. But ...
0
votes
1answer
14 views

Project line segment onto a vertical line

If I had a vertical line (which its x is 0) and 2 vectors which connected together to form a line segment, would it be possible to "project" the line segment onto the vertical line? Eg. If all I had ...
-1
votes
0answers
29 views

Math for moving camera

I implemented camera look around with mouse, but it doesnt look 3d. This imgur shows what i mean better than i can describe it. https://imgur.com/a/gFb7kwX Right now i am using the DX and DY from ...
2
votes
1answer
36 views

How to make a motorcycle running on a vertical circular track(loop-da-loop) without falling down due to gravity?

I am currently developing a game, motorcycle type game. Of course, my map is not just made up of simple line or curve. For example: a vertical circular track in the map. i've seen most 2D motorcycle ...
0
votes
0answers
46 views

Random Item Quality [duplicate]

I'm looking to implement something similar to what RimWorld does in terms of assigning a random item quality based on the skill level of the player. Here is their Wikipedia page for reference: https://...
0
votes
1answer
37 views

Help with the calculation of the usage of my speed stat

I am working on a freeroam, action RPG (before you read further, I am not noobish to programming, plus have friends to help with actual content rather than the base code). Anyway, I am trying in ...
0
votes
0answers
25 views

ray intersection of surfaces created by swiping a curve (shader)

What I want is to swipe any curve into a plane, axis aligned. I made 2d intersection of the cross section then the 2d hieght extruded: - first I want to compute ex: the xz intersections - then using ...
0
votes
0answers
19 views

Lanchester equation + Aggregation : health and power calculation (army attaking)

First, I'm new in this field. I'm working on a game but I stopped at the point that I have to Aggregation or cluster (a group of multiple types of entities) attacking another group of multiple types ...
0
votes
0answers
30 views

Mouse click from screen coordinates to world coordinates in Orthographic projection

I'm trying to draw GL_POINTS at a right clicked mouse position, when I tried the following methods, https://gamedev.stackexchange.com/a/144667/99481 and https://...
0
votes
0answers
15 views

Post-projection depth offset in the vertex shader, how to transform world value into post-projection value?

I want to offset the depth value of a given 3d object in DirectX 11 without changing its on-screen projection, the purpose being to show characters that would normally intersect as if they were ...
0
votes
1answer
21 views

Determine view-matrix with camera placed in a scene graph

My scene is organized with a simple scene graph where the child multiplies its transformation with the one of the parent. For normal objects, likes meshes, this works as expected, but I also want to ...
0
votes
0answers
15 views

Calculating the resulting velocity after a reflection

I am trying to do a simple reflection of a point entity off of an arbitrary surface that contains it. It doesn't have to be physically correct but essentially the goal is to do the following: ...
0
votes
0answers
45 views

Efficient collision detection between triangle and circle

Recently I've been making a game (A bit like Asteroids), and I've come to a point where I need an efficient algorithm for detecting collision between a triangle and a circle. I've checked google, ...
-1
votes
2answers
150 views

How do I calculate the total XP to reach a particular level, when each level takes 10% more?

How do I calculate the amount of XP for a level where the first level is 110, and each level after is 10% more than the last. Preferably to do without a loop because the levels will have to be ...
2
votes
1answer
46 views

Jumping to land x pixels ahead while not really moving (2D)

The player object in my game has its x-axis locked. It can only jump on Y. It's the ground that constantly moves to the left so that it appears like the player is moving to the right. The ground is ...
0
votes
0answers
12 views

Run 3ds Max animated train at specific speed in unity

I have a 3d Max exported Train animation which has animated at speed of 1 in 3Ds max Tool. Now, I have to run the animation at specific speed like 160 kilometer per hour (KMPH). I can easily set the ...
0
votes
0answers
28 views

Ray Sphere Interesection Distances WRONG

The discriminant is not working. This code produces incorrect distances from ray to sphere, but it can tell whether or not the ray does strike the sphere. HOW HARD IS THIS I'VE BEEN TRYING TO DO THIS ...
0
votes
1answer
43 views

libgdx - how to make enemies not overlap

I'm currently making a roguelike shooter in libgdx to get a better understanding of the library but I recently just stumped onto a problem where enemies would overlap each other while tracking the ...
0
votes
1answer
27 views

How can I add acceleration to the movement of an object in a game

Below is the code that I'm using to move an object: ...
0
votes
1answer
61 views

AABB test does not consistently detect edge-to-edge contact when bounds are very different in size

My function compares two AABBs for collision detection, and when they are around the same size it works fine, but I noticed that if I greatly decreased the size of one of them (or augmented the size ...
0
votes
1answer
68 views

Bullet Spray RNG

So I have a Nuclear-Throne like weapon system in my game, and I'm working on bullet spray. Originally, there was equal odds that the bullet sprayed at any angle within the spray range. That felt ...
0
votes
1answer
95 views

Isometric Architecture Map Game Data

I'm not sure this kind of question has been answered yet, if so i'm sorry to duplicate it. My question is rather simple : I'm creating a simple Isometric game with libgdx, i'm using Tiled but only ...
1
vote
0answers
47 views

Why are coordinates converted to [-1, 1] during mouse picking?

I am working on my first 3D game, which contains several vehicles placed on a board. I want to implement mouse picking of the vehicles. I found this great tutorial and used its code. But I don't ...
0
votes
1answer
19 views

How to implement level-player collisions resolution?

I want to create simple collision response system (physical simulation is not required now). It is needed just that player can't go through walls. I consider some variants: - Just create a set of ...
0
votes
2answers
33 views

Vector normalize in Unity

I was watching a tutorial about Vectors in Unity, I understood the meaning of normalizing a vector but I wanna know why do we normalize a vector and if we don't what will happen ?
0
votes
1answer
34 views

How to calculate angle for shooting bullet in 3D?

What I want to know is if I can calculate an angle similar to how I'm doing in 2D and update the x,y,z position of a bullet based on that angle in a similar manner I'm doing the update function below. ...
0
votes
1answer
27 views

Choosing the correct normal for a collision

I have taken the task of building a basic impulse physics engine. Circle vs Circle collision resolution has been done and I moved onto Line vs Circle. I can detect a collision and know that the normal ...
0
votes
1answer
61 views

Define a circle from a point on its circumference and an angle

I'm working on a 2D, top-down driving game with some basic AI vehicles. The AI Vehicles move along a bidirected graph of positions. Each vehicle has a current position (from the graph) and a target ...
1
vote
1answer
79 views

Convert Canvas Space point to local space of a rotated rect?

I got a quite tricky problem: I have my mouse position and my rectangle position in canvas space(screen space but with adjusted scaling). Now I want my mouse position converted to local space of the ...
2
votes
0answers
30 views

How do you find the collision between 3D boxes and 3D QUAD face meshes?

I have an axis aligned bounding boxes for 3D object collision, but I have a complex 3d mesh that's divided into 3d faces so I want to check for bounding boxes and collision with the faces of that ...
0
votes
1answer
73 views

From screen space to world space for a 2D game

I'm making a 2D game and I want the user to be able to position an object in the world using mouse input. After a while I found an answer to 'OpenGL Math - Projecting Screen space to World space ...
0
votes
1answer
51 views

Check whether a vector is to the left or right of another position

I don't know how to decide if my point is on the left or right side of another object. My first thought was to check if x-axis of object1 is bigger or smaller than object2's, but if my objects rotate ...
1
vote
1answer
47 views

Transforming a 2D Grid in 3D Space

Hi everyone, I'm trying to implement a 2D Grid in a simple 3D Editor. Here are some debug-rays I already implemented: Everything is working as intended as long as the object is not rotated. For ...
1
vote
2answers
38 views

Find Entity Orientation In Degrees Given Two Coordinates

I'm trying to find the orientation for an entity, as an angle in [0º-360º). I've searched for an answer and tried to implement something of my own, but it always fails on the edge cases. For a better ...
1
vote
0answers
63 views

How do I create the formula for calculate the damage of a skill

I'm trying to calculate the output damage of a skill. The skill can go up from level 1 to 100, it can scale with own levels and the attack of the character. Here some parameters Edit: I need a ...
2
votes
0answers
67 views

Handling a smooth movement over slopes in a worms like game

I currently have a worms like game with the worms style pixel perfect terrain destruction. Its working well for pushing things around and watching them fall, but for the players movement it feels like ...
0
votes
0answers
45 views

How do I find the texture origin using UV data?

I am writing a map decompiler for the video game Tron 2.0 and its map editor, DEdit. DEdit requires a set of three vectors in order to correctly map textures to each model. The vectors are what I ...
1
vote
1answer
70 views

how to put elements around circle with equal distance?

I know circle formula and know how to draw it. but I want put 4 points on it with equal distance from each other. how can I do that? I work with unity.
0
votes
0answers
20 views

How to find volume of convex 3D shape

I'm not sure what can be said that isn't in the title. The gist of it, is that I have a convex mesh delimited by polygons (can have more than 3 sides), and I want to find it's volume. Is there an ...
21
votes
1answer
2k views

Why do transformation matrices always have an extra dimension? [duplicate]

In 3D math I always see matrices with one additional dimension. For example, in 3D graphics, matrices are always 4x4 and in 2d they are 3x3 matrices. Can anyone explain why?
0
votes
0answers
74 views

Computing depth from position of fragment in world space

I have a raymarching shader which computes the location of a hit on the scene in world space. float3 worldPos = ... ; I can verify that the world position is ...
0
votes
1answer
53 views

How to store 3d transformation in a game?

I am curious what is the best strategy to save 3d transformation of a model. Here are the few choices I think about: 4x4 matrix 4x3 matrix(skip the bottom row of a 4*4 matrix) Dual quaternions with ...
1
vote
2answers
32 views

Rotate A towards B with limited turn rate

I want to rotate A towards B with a fixed turn rate per second. My math skills are very limited and I have no clue in how to accomplish this. Best Regards
0
votes
2answers
61 views

How to calculate object speed so it accelerates exponentially?

Think a rocket or a missile. Completely don't know how to make it start slow and then get progressively faster in an non-linear fashion, given max speed and base acceleration. Curve like this would ...
2
votes
2answers
326 views

How to use Moving Average to avoid lucky streaks in RNG

I spent the last week reading about Luck Mitigation and what a dev can do to avoid extreme cases where the player's psychology will be messed up. I came up to this question How do I avoid “too” lucky ...
0
votes
1answer
93 views

Rendering an isometric tilemap

I have a tile which is 512x256 pixels and I'm trying to render it in an isometric fashion. I have this helper function: ...
0
votes
1answer
79 views

Implementing a score system similar to Moon Patrol

I am working on an Android game scenario inspired by Moon Patrol. My beta version is available for beta test from https://play.google.com/store/apps/details?id=dev.android.buggy In my case, I got ...
0
votes
0answers
23 views

Predict Future trajectory of object with friction and changing direction over time

I have an moving character. I know these variables: Current Acceleration (constant) Velocity Ground Friction Current Location Destination (direction of acceleration vector * arbitrary number) as ...
4
votes
3answers
114 views

How to find the degree of interpolation?

I have two quaternions: A and B. I want to lerp between them. Given another quaternion C, I ...
0
votes
0answers
20 views

Failing to apply Max Rectangle algorithm

After asking this question, I have few problems trying to implement Max Rectangle Algorithm that is described here on page 19. I have a hard time implementing this, do you have leads or advices on ...