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

Questions tagged [mathematics]

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

0
votes
0answers
18 views

Is it possible to generate a 2D surface that approaches certain mesh, and then a specialised ray-tracing function for it?

As an example, suppose we are trying to ray-trace a sphere. There are two options. The first one is to build a mesh of triangles approximating the sphere and ray trace it. Unfortunately, the more ...
0
votes
0answers
22 views

Calculating Damage from from object collision

I need to calculate the damage resulting from a crash of two objects. I found the formula of the resulting kinetic energy: E = m * v² / 2 I guess I also have to ...
0
votes
1answer
20 views

Interpreting focal length in units of pixels

I am working on a renderer of sorts and I have some fundamental questions. Let's say I have a vector in a 3D virtual world space which is unitless, and I want to project it onto a 2D screen, so I need ...
0
votes
0answers
25 views

Mapping between a sphere and a cube

I'm developing a game that procedurally generates terrains with a voxel engine. These terrains are essentially flat cubes that trail off into infinity on the x and z axes. y is basically the altitude, ...
0
votes
0answers
19 views

Rotate projectile toward target [on hold]

Rotating a projectile toward a target Say I had a bullet a character shoots at an enemy. If the enemy was directly above me I want the bullet to be rotated at a 90 degree angle. Or if the bullet ...
0
votes
1answer
23 views

draw concave polygon from set of edge points

I'm having troubles trying to rearrange a set of points where each point is part of the edge of a concave polygone. My set of points is not sorted in any order, they are just randomly put in an array. ...
0
votes
1answer
26 views

Unity - Calculating a rotation based on game time

I have a simple script to make an object spin: Spin Speed is the speed to rotate the object on each axis (preferably in degrees per second). Local is whether the rotation should be done based on ...
0
votes
0answers
18 views

Drawing ortho outline of rotated elipsoid

I'm working on a collision system for a 2.5D game, and I'm stuck on the sphereoids. As long as scaling x=y=z, and it doesn't rotate, I can just use an r^2 check, but I'm trying to figure out a way to ...
1
vote
2answers
50 views

Getting Model View Matrix by hand

Right now I'm trying to calculate the model view MAtrix by hand... The App is 2D. I have Somethign like this.. ...
0
votes
0answers
23 views

btRigidBody world transform and scale issue

When I create a collision shape for rigid body (in this case box) I use vertices positions and scale from the opengl matrix, the code looks this way: ...
0
votes
1answer
38 views

Wrong angles given by atan2

I have a method to calculate angle between two vectors, but it is giving wrong values. here is the code : ...
0
votes
1answer
13 views

Get closest point on box to line

Eventually this problem will be 3D. My player is looking forwards. There is an axis-aligned box on the screen (FOV is guaranteed to be 90, so boxes behind the player aren't considered.) I want to ...
0
votes
0answers
47 views

How can I make this tile map correctly?

I'm having the following problem creating this hexa tiled map. this is what I wanted : [EDIT] Ok I've Managed to do this: ...
0
votes
0answers
10 views

Find The Angle Needed for Hitting a Target with Air Resistance [duplicate]

I'm looking for a formula to hit a target on an xy plane. How can I calculate the angle needed to hit the target with a given distance and projectile velocity? I want to incorporate simulated air ...
0
votes
1answer
62 views

How is raycasting implemented

I know what it's used for, I know what it does. What I am essentially asking is what is the math/code behind how it works? I'm aware that any custom implementation would likely be slower than an ...
-1
votes
0answers
21 views

Python Pygame collision help with my game

I'm creating a game in Pygame where a snowboarder will be going down a hill in 2D. I need to figure out how I can detect collision when the snowboarder (shape of line) hits another line (hill) on one ...
0
votes
1answer
162 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
65 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
85 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
0answers
22 views

Create AABB Cube from click-and-drag user rectangle? AABB OBB Collision Detection

I'm trying to create a 3D cube from rectangle drawn by ther user's mouse (think click-and-drag selection). My end goal is to use this to implement entity click-and-drag box selection. If you've played ...
0
votes
1answer
35 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 ...
0
votes
0answers
38 views

2:1 Diametric Projection in 2D

I'm trying to implement a 2D isometric game, well diametric with a 2:1 pixel ratio. Trouble is the rotation matrix I made doesn't seem to work. It's off by a little bit and doesn't line up: I'm not ...
0
votes
0answers
22 views

How to detect if a point is below a bounding box (thread-safe)?

I am trying to cast a shadow on a set of points in Unity that are below a BoxCollider object (have an x and z that would be in the box but y is below it). I ...
1
vote
2answers
54 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
42 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
63 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
187 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
62 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
41 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
20 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
44 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
40 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
37 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
1answer
25 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: ...
-1
votes
2answers
159 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
49 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
14 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
34 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
67 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
28 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
82 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
72 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
134 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
48 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
44 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
49 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
41 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
40 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 ...