Skip to main content

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
1 answer
44 views

How can a quad be triangulated consistently in 3D? [duplicate]

I'm making a building game and the terrain and modelling system are based on cubes made out of 8 corners each. Players can manipulate the corners to make other shapes. When you take a quad (ABCD), ...
Paulo Vinícius Bettio's user avatar
0 votes
0 answers
11 views

Implementing 3d isometric like camera in Unreal BP

Im trying to learn Blueprints and started by implementing my own isometric view from scratch. I have a pawn, with a camera component, the view is supposed to rotate and scroll. I have implemented ...
rogerdv's user avatar
  • 31
0 votes
3 answers
146 views

How do large physics based games (space engineers) deal with coordinates

I have recently been looking into physics engines and low level computing. At some point id like to make my own engine down the road. Something I can't seem to find an aswer for is how physics based ...
TizWarp's user avatar
0 votes
0 answers
76 views

Normals deformation with FFD

I am developing an FFD tool in Unity for the needs of a level designer. It works similarly to FFD box in 3DS Max. I used the implementation described by Sederberg and Parry with a lattice and ...
Ruptis's user avatar
  • 1
1 vote
2 answers
68 views

Inconsistent Movement Behaviour between built Game and Playmode

I'm using a simple MonoBehaviour that causes GameObjects to change their position based on a ...
DemonicTree's user avatar
0 votes
1 answer
119 views

How to calculate the center of mass of a irregular polygon in Godot?

Or to calculate the centroid of a 2D polygon assuming uniform mass density, which is my case. The polygon can be either concave or convex.
Alejandro Garcia's user avatar
1 vote
1 answer
114 views

How to calculate the surface area of a irregular 2D polygon in Godot?

I have a irregular 2D polygon, it is a PackedVector2Array, how do I get its area?
Alejandro Garcia's user avatar
0 votes
1 answer
123 views

How to live on sphere?

What I want to achieve I want to generate sphere planet world, seamless of course, for RTS game like Planetary Annihilation: TITANS, which means I want: place walking agents on sphere, move them on a ...
Tony Max's user avatar
0 votes
0 answers
14 views

How to find offsets of Vector2's give number of points row, amount of points, and centered vertically?

Say that I want to make a grid that contains 5 points and up to 3 points on each row. starting from the top I should have 3 points followed by 2 points underneath centered by the same distance like so:...
Anthony's user avatar
0 votes
1 answer
37 views

Calculating semicircle points of a scaled CapsuleCollider2D

I have a very simple code that draws the shape of a pre-defined capsule. It handles everything well, except the case when the GameObject to which the ...
Digika's user avatar
  • 1
0 votes
0 answers
57 views

Collision of two rigid spheres with spin

I'm trying to create a particle simulation (solar system kind). Until now my particles have no spin so the collision is rather simple ...
S M's user avatar
  • 101
0 votes
0 answers
43 views

2d top down movement physics: speed, max speed, acceleration, friction, velocity, delta

I am creating a 2d top down game and am trying to implement movement. My current approach is very simple and looks like this ...
Aeon's user avatar
  • 1
1 vote
0 answers
48 views

Predictive Aim to shoot a moving target with a constant velocity while the projectile is affected by gravity (2D/Platformer view)

I've been working on creating stationary gun turrets that can shoot down missiles in my game. The bullets are affected by gravity while the missile moves in a linear path at a constant rate as if it ...
TheFactoryIndustry's user avatar
0 votes
0 answers
44 views

How to make an object keep same relative position and orientation using only velocity

I have object A, I can get any information I want from object A (global position, velocity, etc) I have object B, which is positioned and oriented in a certain way relative to object B. There is no ...
Frédéric Bélanger's user avatar
1 vote
0 answers
20 views

2 object snapping using bounding boxes in Unity Runtime

I am using boundary boxes for all calculations. In the image below you may see a case where this objects need to be snapped. Currently the calculations go as following, the rotation is changed by the ...
Artak's user avatar
  • 11
0 votes
2 answers
152 views

Normalize an angle in unity

How can I normalize angle between min value and max value? like normalizing -1136316.78186234° between 0° , 360° or between 180° , 360°. Node: for now I'm using double value as angle. Thanks for ...
Ahmed Dyaa's user avatar
0 votes
1 answer
16 views

Selection Box Not Positioning Correctly

I found some code that generates a selection box, but when I tried it the box was not starting where the mouse was and I couldn't find the issue. ...
PizzaLvr49's user avatar
0 votes
0 answers
45 views

Matrix parent-child transformation for 2D positioning

I am working with matrix math for parent / child transformations. I have to modify existing calculations to keep child scale constant while also keeping child position relative to its parent. Here's ...
Karli Casper's user avatar
0 votes
0 answers
35 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
61 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
97 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
78 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
72 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
113 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
47 views

Camera (View) in Euler angles

This is code (below) from original game project (90s years), I it study now. Used fixed point math. ...
black4joss's user avatar
0 votes
0 answers
75 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
81 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 ...
black4joss's user avatar
0 votes
1 answer
115 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
46 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
45 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
67 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
186 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
75 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
  • 437
0 votes
1 answer
130 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
  • 137
-1 votes
1 answer
112 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
130 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
31 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 ...
black4joss's user avatar
-1 votes
1 answer
108 views

What this code do?

I investigate source code old game for 90s, dont understand math stuff. ...
black4joss's user avatar
0 votes
2 answers
112 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
63 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
75 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
297 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
114 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
148 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
163 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
157 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
262 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
152 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

1
2 3 4 5
41