Stack Exchange Network

Stack Exchange network consists of 175 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

Questions tagged [mathematics]

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

0
votes
1answer
399 views

How to calculate the surface area of a mesh

I am looking for a way to calculate surface area of a 3D mesh object and found this code from a Unity forum: ...
0
votes
1answer
71 views

Perspective Matrix doesn't work OpenGL 4

I tried to implement my own perspective matrix and it doesn't work. I don't understand why. With just with my view matrix (without Perspective Matrix) I can see my mesh. Here my view matrix : ...
0
votes
1answer
106 views

Help me adjust this RPG logarithmic leveling formula! [duplicate]

I'm trying to find a formula that's fits the way I want my player to gain experience and level up. I know this is primarily opinion based but I hope someone can help me! I've used the following ...
0
votes
1answer
55 views

Top down off-screen indicator, Unity3D C#

I'm working on a top-down 3D game where things spawn off camera. Movement only occurs on 2 axis (x and z). Rotation is about y axis. The player is in the center of the camera and needs to have ...
1
vote
2answers
55 views

Trying to find a function to calculate attribute changes in a game

I'm coding a game where after every year depending on results the attributes of characters change. The game is a movie business simulator and here is a example of the ugly code I have in place now: <...
0
votes
1answer
50 views

Quaternion representing rotation from shoulder to hand

I am provided with 3 quaternions. One for the shoulder, one for the elbow, and one for the hand. What I want is to obtain a single quaternion representing the rotation from the shoulder to the hand, ...
2
votes
1answer
67 views

How can I express Logarithmic and Arithmetic spirals as segmented cubic bezier curves?

I am creating cubic bezier curves using this code from another question I asked. I would like to know how I can express Logarithmic and Arithmetic spirals as segmented cubic bezier curves.
3
votes
1answer
191 views

What is the physics behind a 2D gravity tunnel?

In Portal 2, there is a concept of an "excursion funnel", a beam of light that moves physical objects in a certain direction. Here is a link to a demonstration. I added a simple implementation that ...
0
votes
1answer
80 views

Combine rotation XZ (horizontal) with YZ (vertical). Math formula

I'm trying to make a rotation vertically and horizontally around a point at the same time but I'm not able to combine both. I have this formula for the horizontal rotation: ...
1
vote
0answers
42 views

Center of Mass for Convex shape in 3D

For an arbitrary convex shape in 3D, how can I calculate its center-of-gravity? I have face-normals, and the vertices for each face. @Ocelot No, it most certainly is not the average of the vertices, ...
1
vote
1answer
24 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 ...
2
votes
1answer
47 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
1answer
41 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
1answer
33 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
16 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: ...
-1
votes
2answers
164 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
51 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
20 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
40 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
84 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
31 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
92 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
76 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 ...
1
vote
1answer
180 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
49 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
49 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
103 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
46 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
56 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
64 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
100 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
84 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
352 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
182 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
81 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
3answers
60 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
86 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
78 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
56 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
74 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.
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
192 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
66 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
35 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 ...
3
votes
3answers
402 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
133 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
91 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
31 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
133 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 ...