Questions tagged [mathematics]
Mathematics questions deal with the arithmetic, geometry, calculus, formulae and other calculations used in the development of a game.
1,967
questions
-1
votes
0
answers
47
views
other objects are moving with player [closed]
I was trying to locate other objects in world space but they where moving with camera and I couldn't able to locate them, Camera is moving with Player Car but other Obstacle cars are also moving
...
0
votes
2
answers
58
views
Simulate Velocity For A Projectile Moving Along A Spline
I'm using Unity's latest Splines package(v2.5) to move a projectile across a spline with speed. It works perfectly and the projectile moves across the spline to it's target with linear speed.
But I'd ...
0
votes
1
answer
69
views
How to properly split damage against armor?
I am developing a third-person shooting style game and I want to implement an armor system. The system that I have envisioned does not reduce the damage to 0, but by half. So the incoming damage is ...
0
votes
1
answer
117
views
Inconsistent Speed Of A Projectile Traveling On A Bezier Curve
What I'm doing:
I'm moving a projectile to it's target along a Bézier curve with one control point.
The projectile moves from Transform A to ...
2
votes
2
answers
102
views
Calculating average ttk given accuracy and healing
I'm trying to calculate the expected ttk for weapons in my game but I'm having trouble because players can miss and enemies can heal.
Let's say an enemy has 100 health and every second you have a \$p\$...
0
votes
4
answers
121
views
How to tell whether an expression is independent from frame rate?
I'm working on a videogame where part of the logic involves increasing a value each render frame (a render frame is equivalent to a simulation step where the result is drawn on the screen).
Frames can ...
0
votes
0
answers
47
views
Determining meters per second in scaled terrain
I have a terrain with a width of 199 and height of 99 and I'm scaling this train by 500. What would be 1 meter in the new terrain, would it be 500? I'm trying to move my character in meters per second ...
0
votes
1
answer
59
views
Test if a point is inside a 3D cuboid, given the 8 corner positions, through code
I'm trying to find to obtain if a point, let's call it "v" is inside a cuboid which every corner position named P1 to P8
I am trying to achieve this and in fact found some answers in some ...
0
votes
2
answers
70
views
Euler Angle X is wrong after using Quaternion.LookRotation
I have an direction that I want the local player hub & camera to rotate at.
The game handles this by using euler angles which Y represents the hub rotation on the horizontal axis & X ...
0
votes
0
answers
23
views
Raycaster rotation problem
I am following lodevs tutorial on Raycasting https://lodev.org/cgtutor/raycasting.html.
I was kinda successfull but for some reason while implementing a 2D Topdown view of the map and the player i ...
0
votes
3
answers
168
views
A good genetic system?
I was trying to come up with a genetic system for my game. However, after doing the math I found the system I had in mind won't really work.
Characters have 5 stats that can range from 0 to 12. What I ...
0
votes
2
answers
181
views
How do I use these Unity math functions in Godot C#?
Here's a list of math functions I'm having trouble finding a direct function match for in Godot C#:
...
1
vote
1
answer
71
views
Adaptation of values from previous constant frame rate to new constant frame rate
I'm trying to learn how to adapt my old values to new values. First of all, I don't use delta time at all. My game has lock with 30 FPS and I want to lock it with 60 FPS, I wrote all my values in ...
1
vote
1
answer
94
views
Twin-stick backwards tank movement
I'm creating a 3D twin-stick tank game in Godot with C#. I have created the tank movement and rotation, separate of its turret, and it seems to be working properly.
The issue: I want the body of the ...
2
votes
1
answer
124
views
Calculation of far distance plane based on yaw and pitch for a map renderer
I'm working on a vector map renderer. I want to calculate the far plane for a protective transformation, based on the yaw, pitch, roll and height of the camera above the map. Yaw (looking to the left ...
1
vote
1
answer
57
views
Vertex Shader Sphere Projection and CPU Distance Calculation
I have multiple planes whose vertices are transformed to a position on a sphere in the vertex shader. The GLSL function called pointToSphere transforms a point <...
0
votes
0
answers
30
views
Missing tiles when rendering an isometric Staggered tilemap in Unity
I'm trying to show tiles on an isometric staggered tilemap in Unity, but some tiles are missing. I think the problem might be with where I'm placing the tiles or some floating-point precision issues.
...
0
votes
1
answer
54
views
How to calculate angular momentum of two colliding bodies about their shared center of mass in 2D?
I'm following this guide to implementing collisions in 2D physics.
It shows this diagram, but I don't understand how to calculate the values of Da and ...
0
votes
0
answers
150
views
Finding loss of angle and length due to rotation
I'm working on a targeting system for my 2d game. But I want to see the object in isometric perspective. My calculation is correct for 2d objects but it doesn't work for rotated in x axis objects.
I ...
1
vote
4
answers
221
views
Why should a game include a range of possible damage values per hit?
I’m asking this because this reminds me of critical hits, preventing battles from being too predictable, BUT if I already have crits… why would I have damage ranges?
Especially in action games, there’...
1
vote
1
answer
309
views
How to compare a vector to a rotation in Godot 4.1?
The Context
In Godot 4.1, I have a third-person character controller. It's a CharacterBody3D with a child Node3D called PlayerContent. The visual components of the character (model, etc.) are all ...
0
votes
0
answers
20
views
Isometric camera lookat
I'm trying to make my isometric camera follow my player or lookat any other object
projection matrix is
...
2
votes
2
answers
98
views
Finding the closest point on a circle to end of a ray in 3D
I have a circle in 3D space, so we have center C with radius r, and the normal of plane the circle lies on, N. There is also a normalized vector V that I am modifying to go far past the circle's ...
0
votes
0
answers
25
views
Rotate the parent object so that the child object points to the cursor 2D [duplicate]
I have an arm that has a pivot point on it. I want to rotate the arm so that the barrel of the gun points to the cursor. How do I calculate the angle of rotation for the arm?
I'm not very good at math ...
0
votes
0
answers
103
views
Implementing Camera Movement and Rotation in 3D Game Engine
Apologies in advance for any mistakes on terminology, I'm really really new to this
I'm completely new to 3d (and it's maths) but as a personal exercise I'm doing my own game engine that displays a ...
1
vote
2
answers
97
views
Determine which direction to rotate
Not sure if this belongs here or on the Math Exchange site; it's probably a simple math concept that I'm missing.
I have a 2D sprite with a rotation (let's call it A), and I want to slowly rotate it ...
1
vote
0
answers
40
views
Trying to plot trajectory of rocket using only its current position and velocity components
I have a 2D controllable rocket for which I want to plot the parabolic motion. Additionally, the parabola should be able to change due to the thrust of the rocket accelerating it in either direction. ...
1
vote
0
answers
42
views
Problems with RayCasting after fixing fisheye distortion
I am writing a pseudo-3D game in Python. After I tried to fix the fisheye problem, a new one appeared - if you stand close to the wall and look so that the wall is on the side, then the borders of the ...
0
votes
0
answers
29
views
Converting Hours and Minutes to Radians
I just added a day and night cycle to my game, and I'm trying to update the shadows based upon the current time of day. I found some code online which supposedly converts hours and minutes to radians, ...
0
votes
1
answer
110
views
How to convert a Unity transform to Maya's coordinate system?
I created a level in Unity, and I want to place some of the level objects in Maya so I can create an animation based on these objects.
I can import the model FBX with no problems into Maya, but if I ...
2
votes
2
answers
159
views
Math formula for game attack speed
I want to create a function for a game stat of attack speed, but I cannot figure out how to write a math function for this.
My formula should work in a way, if attack speed is 200%, it does 4 hits per ...
0
votes
1
answer
86
views
Unprojecting screen space to world space stops working when camera not at origin
I'm trying to implement screen space to world space in my engine to allow object selection in editor. I understand that the process should essentially be the reverse of projection. So to go from world ...
0
votes
2
answers
134
views
How to implement diminishing returns for multiplicative character stats?
I'm very bad at math, ridiculously so. I'm making attributes that work as multipliers.
1 Agility means :
animation speed * agility, ...
1
vote
2
answers
97
views
In a 3D projection, how to find 'w' for every y point on the screen
I have a standard 3D rendering pipeline. Let's say I have a camera looking down at a flat plane that represents the floor. (in my game, z = height, so this is a plane where z == 0), and for ...
1
vote
2
answers
68
views
How to paint a circle of pixels so that at diameter=3 the result is a cross shape?
I have a pixel art brush and a canvas. When the brush size is 3, I want to draw a cross shape instead of a 3x3 square.
I implemented the following formula: if the distance between two points is less ...
0
votes
2
answers
96
views
How "Dodge" characteristic is calculated on enemy troops
I was torn about whether to post this as a game problem or as a maths problem. My maths is a little shaky, so thought maybe best to post here. The game, for anyone who is familiar with it, is War and ...
0
votes
1
answer
103
views
Optimizing Tax Revenue In City Builder Game
I am currently developing a city builder game that incorporates a tax revenue system, allowing players to redeem their city's tax revenue every 24 hours. I want to create a mathematical model for tax ...
0
votes
1
answer
58
views
Calculating score for a level with time and lives variation
I am developing a game where based on steps to be performed in a particular level, time and lives are pre-calculated.
As the level gets completed, remaining lives and time are retrieved.
Calculating ...
1
vote
1
answer
97
views
How do you rotate an object that uses a quaternion to represent orientation in 3D from a 3 vector input with values from a gamepad?
I'm using unity3d to create a six-degree of freedom flying game. The game takes in input from a standard dual-stick gamepad (like the Logitech f310).
In unity each of the gamepad's joystick's axes are ...
0
votes
2
answers
97
views
Randomization algorithm that trades between more variance and higher total value
I need to generate discrete integer variables that each have meaning, so does their sum. I am essentially looking to partition a normal distribution into n bins. You can think of them as stats. The ...
0
votes
0
answers
43
views
Normalise movement for direction with 16:9 aspect
should i move everything by the windows Normalised cords to make it so SE is bottom-right, or should i use (1,1) and move everything at or either (1+speedX,1+speedY)
...
0
votes
1
answer
49
views
moving an object around a Circle [closed]
I am going to draw a shape like a gear, how can I move a tooth around a circle?
Something like the image below :
For example, I need to draw 20 teeth at equal intervals around a circle with a ...
0
votes
1
answer
136
views
How to limit forces based on linear velocity
I'm trying to develop a system where there are two types of velocity limits.
The velocity that a rigid body can achieve on its own.
The velocity cap which is reachable by interference with other ...
0
votes
0
answers
33
views
How do I calculate the position and rotation where 3 given vectors would intersect 3 given points
I have 3 normalized directional vectors and 3 points.
The 3 vectors are all attached to the same object, and I would like them to keep their angles relative to each other.
I want to find a location ...
0
votes
1
answer
78
views
Help with understanding Vector3 math
I was making a 3rd person player controller in Unity.
Would
Vector3 inputDirection = orientation.forward * verticalInput + orientation.right * horizontalInput;
be ...
0
votes
0
answers
75
views
Group voxels into object?
I'm working on Voxel editing software, and I need to have the ability to group voxels into objects.
As for simple editing, I'm using the following data structure:
Chunk - represents a fixed 3d grid ...
0
votes
1
answer
45
views
Score count-up speed based on music
I'm trying to implement a score count-up that is synced with the tempo of some short music jingle, but I'm failing on calculating the math for it.
Let's say I have a total score of 2000 that I want to ...
2
votes
0
answers
70
views
Calculating spring constant c
Suppose we have 2 springs with different values for m and k. The first spring is given an arbitrary dampening value, ...
1
vote
1
answer
193
views
RPG formulas for dodge/evasion and lockpicking rolls
Im trying to figure out some way to implement a formula to calculate dodge and evasion in my game in some reliable way. The factor involved are dodge/evasion skill levels, of course, the target's ...
1
vote
1
answer
97
views
Sliding scale for secondary stats
So, I’m designing a game where Crit Chance is based on a Prowess Stat but want it to have a sliding scale with diminishing returns and for some reason the math is escaping me. The max value for Crit ...