Questions tagged [mathematics]

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

Filter by
Sorted by
Tagged with
0 votes
0 answers
16 views

Texture space Raytracing of cylinder primitive in godot shader for Helix interception

I have been trying to do raytracing of an helix in a spatial shader in godot 4.2, but apparently I missed something because the result is bloby and melty at the cylinder level. The basics is that I ...
user29244's user avatar
  • 327
0 votes
0 answers
48 views

How to calculate velocity based on force at an angle

I have a 2D top-down jetboat that is moving (has a x, y velocity). I apply the velocity by multiplying against the delta time <...
fresh's user avatar
  • 1
1 vote
1 answer
67 views

Mirroring a Character's Position In a Shadow After Rotating 180 Degrees

Description: I am creating a 2.5D RPG. When my character moves from left to right, they rotate 180 degrees to face the new direction. Just like this example. They also have a blob shadow sprite that ...
PayasoPrince's user avatar
11 votes
3 answers
3k views

How hard to brake to perfectly smoothly reach the destination?

Goal I want the get the required minimum deceleration to perfectly smoothly reach a target. (The car's AI should know how hard it has to brake to be the perfect valet.) Research "How can I ...
st_phan's user avatar
  • 213
0 votes
2 answers
66 views

How to rotate spaceship quaternion to face target direction with constant angular speed?

I have an enemy spaceship, and I want to make it turn to face the player with (for now) a constant angular speed. The ship's orientation is a quaternion. How do I do this? Since this is totally free ...
Tachytaenius's user avatar
1 vote
1 answer
67 views

How to calculate rotation needed to cancel out perspective shift

I have a direction vector that's pointing to (0,0,1) in local object space. How can I calculate rotation needed to rotate it on Y axis so that from camera's point of view it would look as if it's ...
JuliusJ's user avatar
  • 13
0 votes
2 answers
109 views

Max velocity for smooth deceleration to destination

I am able to update velocity of my agent every 0.5 seconds. My agents max speed is 5f/s and max acceleration/deceleration is 2f/s. I know how far away I am from the destination. How to determine ...
Peter's user avatar
  • 13
0 votes
0 answers
39 views

Camera (View) in Euler angles

This is code (below) from original game project (90s years), I it study now. Used fixed point math. ...
black4's user avatar
  • 175
0 votes
0 answers
56 views

How to make calculating the inverse matrix more robust?

When I calculated the inverse matrix, I found that the error in using the float data type would cause the inverse matrix calculation error. Is there any good solution? ...
noodle_run's user avatar
0 votes
1 answer
71 views

Software rendering - compose View matrix

There is function compose View Matrix, it's software rendering project. Used fixed point math. phd_sin() and phd_cos() user defined functions implement sin() and cos(). Please explain this ...
black4's user avatar
  • 175
0 votes
1 answer
87 views

Normalized coordinates not translating to screen coordinates the way I need them to

I am making a simple game in C# using pictureboxes. I want to move a picturebox on a form. Once this picturebox is placed in a new location, I normalize its X,Y coordinates between [0, 1] and then ...
CluelessWizard's user avatar
0 votes
1 answer
44 views

Checking if I am looking through a window using angles

I am developing a mod for a game with a Lua api. I am trying to detect if I am looking through from behind a window when I shoot an enemy. For context, when I shoot through this window I apply a ...
Ben R's user avatar
  • 1
0 votes
0 answers
39 views

Determining a direction/projection/heading for an object in 3D space after it has been rotated

I hope this is a good place to find an answer. I'm not a math wiz and I've tried to tackle this problem many times over the past decade or so. I have a 3D space world, and I'm in a little space ship. ...
edasac's user avatar
  • 1
0 votes
2 answers
63 views

Calculate damage when attacker has bonus but defender has resist

Let's say an archer does base damage of 50. But their equipment provides +30% bow damage to make the damage ...
kmoney12's user avatar
  • 101
1 vote
2 answers
162 views

Calculate path segments size

I have a problem more closely described on a picture below. The idea is that I have my agent in point A and I want to get to the point B. The problem is, that agents rotation towards point B is alpha ...
Peter's user avatar
  • 13
0 votes
1 answer
71 views

How to correctly instantiate a cube over another, or side-by-side another one

In a Minecraft spawn system like, I can't make works correctly following code. Specifically, if I use Code 1 it works only when I instantiate a cube over another one, not one aside other. The ...
stighy's user avatar
  • 427
0 votes
1 answer
86 views

How does vector raised to the power of another vector work?

I was watching this tutorial and at timestamp 3:03 he did this: This blows my mind because I didn't expect that to actually work, how the heck does that work ???? For example, if I have vector (2, 3, ...
aaa's user avatar
  • 107
-1 votes
1 answer
90 views

Angry Birds style aiming (ballistic trajectory)

Could you please provide guidance on how to create the curved part? regard,
Saeed Asmani's user avatar
0 votes
1 answer
100 views

Min - Max Weapon Damage formula in video games

I currently working on an RPG game and I'm looking for are formula for creating/generating a min-max weapon damage for an item. Why in Diablo for example, when a weapon is dropped from an enemy, the ...
Eli's user avatar
  • 3
0 votes
1 answer
29 views

Difference of angle by Y value

This code from game 90s years. For example on scene there is tiger as "item" and main character as "enemy". This code calculate vector or direction of attack tiger to main ...
black4's user avatar
  • 175
-1 votes
1 answer
107 views

What this code do?

I investigate source code old game for 90s, dont understand math stuff. ...
black4's user avatar
  • 175
0 votes
2 answers
94 views

How to compute XP thresholds when scaling changes for each level range?

I am developing mobile game and I am stuck on an issue regarding proper player stats scaling based on level. As a parameters for the computation we have: base XP value multiple increment values (for ...
Jakub M's user avatar
0 votes
0 answers
60 views

Is this gimbal lock I'm hitting even with rotation matrices / quaternions?

I'm spawning a trigger box relative to another object using local offset. The engine I'm using does not provide a native function to make that conversion (at least in a way accessible to me), so I am ...
Drew's user avatar
  • 176
0 votes
0 answers
54 views

When does normalization happen in the perspective projection matrix

I am currently watching this video where the instructor shows how the perspective project matrix is actually derived. There are a few things that I am still unclear of. Firstly he says we need to ...
Shaharyar Ahmed's user avatar
0 votes
3 answers
163 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 ...
PayasoPrince's user avatar
1 vote
1 answer
105 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 ...
Daniel Rudy's user avatar
0 votes
1 answer
132 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 ...
PayasoPrince's user avatar
2 votes
2 answers
134 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\$...
Devon Rutledge's user avatar
0 votes
4 answers
143 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 ...
Marcos Pereira's user avatar
0 votes
0 answers
56 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 ...
blov's user avatar
  • 1
0 votes
1 answer
136 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 ...
user57129's user avatar
  • 121
0 votes
2 answers
109 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 ...
Xprt's user avatar
  • 3
0 votes
0 answers
32 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 ...
Atem's user avatar
  • 1
0 votes
3 answers
191 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 ...
user avatar
0 votes
2 answers
249 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#: ...
Ethan's user avatar
  • 145
1 vote
1 answer
76 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 ...
dt_'s user avatar
  • 11
1 vote
1 answer
107 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 ...
Reinier de Vries's user avatar
2 votes
1 answer
210 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 ...
maxammann's user avatar
  • 123
1 vote
1 answer
98 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 <...
Miguel Myers's user avatar
0 votes
0 answers
36 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. ...
Nick785's user avatar
0 votes
1 answer
73 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 ...
noodle_run's user avatar
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 ...
26.565's user avatar
  • 1
1 vote
4 answers
265 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’...
Verbran's user avatar
  • 11
1 vote
1 answer
810 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 ...
Legoman's user avatar
  • 163
0 votes
0 answers
28 views

Isometric camera lookat

I'm trying to make my isometric camera follow my player or lookat any other object projection matrix is ...
anotherone's user avatar
2 votes
2 answers
161 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 ...
A well-rested dog's user avatar
0 votes
0 answers
26 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 ...
Haslin's user avatar
  • 1
0 votes
0 answers
225 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 ...
MiguelP's user avatar
  • 103
1 vote
2 answers
202 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 ...
AwoeDace's user avatar
  • 113
1 vote
0 answers
46 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. ...
confused_aspirant's user avatar

1
2 3 4 5
40