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
0answers
17 views

Intersection of ray and non-axis-aligned box

I need to compute the intersection of a ray with a non-axis aligned box. Currently, I transform the ray into the local space of the box, do classic ray-AABB intersection and transform the intersection ...
0
votes
1answer
21 views

2d navigation for physics-based car

i'm making a game, one npc is a car with spear in head, he try to hit the enemy (yellow pot in image) with the spear point. here is the promble ,the car is physics-based , it has veloctiy ,max ...
0
votes
1answer
37 views

Check if point is inside convex hull

I first tried with a simple axis aligned bounding box to test my algorithm (later shape will be different but always convex 6 faces), but even this case did not work, it always tells me that the point ...
1
vote
1answer
90 views

Octagon border algorithm

I'm working on an open source game for 2 years but I'm very bad at math. The game permits moving a character on an octagonal basis. When the character reaches the border coordinate (colored in yellow),...
0
votes
1answer
36 views

how to track point on object with rotation

I'm working on a top down shooter in C++ and need to have a fire point on the player and npc's so that when they rotate bullets come out of the fire point and not the actual position here's what i ...
0
votes
1answer
28 views

How to get x in radius percentage value?

How to find the percentage value from A to B when I know the X value in between these two points? I created this picture to kind of illustrate what I mean better. I wrote this function which gets ...
0
votes
0answers
29 views

Player losing alignment with tilemap after moving

I'm using an isometric tilemap(2:1) and I can't figure out how to make grid based movement on it's surface. I managed to get a code working for the grid based movement, moving my character with 0.5 ...
1
vote
1answer
20 views

Unity difficulty placing text within the reference resolution of the canvas

I have a TextMeshPro GameObject, which I placed within the Canvas. The canvas is set to Scale with Screen Size and has a reference resolution of 1440x1080. The ...
0
votes
1answer
23 views

How to keep the object rotation while using RotateAround in Unity?

I've got an object that has a comet-like sprite rotating around it. I'm using this code in LateUpdate() to make it rotate and keep the comet's tail at the right ...
0
votes
0answers
19 views

How to make 2D particle explosion

So as in the title I want to know how I accomplish an explosion effect with particles. So far I am able to generate particles in a random position and they just fade out. What do I need to make the ...
2
votes
0answers
548 views

Idle game: calculating resource generation/consumption

I'm making an idle game in the vein of Melvor Idle and I've run into a problem calculating the yield and consumption of resources while the user is away. For those who don't know, many idle games have ...
0
votes
1answer
32 views

Mathematical equation for CHOMP AI?

Players take turns in taking a rectangular bite out of the bottom right corner of the bar, by shading a square, tighter with all the squares below and/ or to the right it. The top left-hand square is ...
1
vote
1answer
37 views

Function to draw an image inside a rectangle

How can I draw an image inside a rectangle? I am introducing myself in the manipulation of images for games, I have a window and inside there is a rectangle that deforms. I would like to fill the ...
0
votes
1answer
15 views

How to scale smaller values more

Hello it seems like it should be easy and i am missing something but i really couldn't find a solution as i am fairly new to programming. So basically i want to rotate a object faster when its closer ...
0
votes
0answers
17 views

Swapping Y and Z in quaternion [duplicate]

I am converting between coordinate systems where Z is the vertical axis in one, and Y in another. I have the rotation values represented as a quaternion. I see this related issue but it's switching ...
1
vote
1answer
96 views

What is the use case for slerp in 2D?

When searching for slerp, I get this text: Slerp is shorthand for spherical linear interpolation, introduced by Ken Shoemake in the context of quaternion interpolation for the purpose of animating ...
0
votes
0answers
26 views

Strange deviations while implementing alpha compositing

I've been trying to create my own 2d renderer for my game (for learning purposes) and I'm trying to implement alpha compositing. The formula I'm using is very trivial, which is ...
0
votes
0answers
13 views

How variance shadow maps moments fall into Chebyshev's inequality

I'm having hard time understanding how the moments fall into place into Chebyshev's inequality. I'm reading about the technique in the following article. In the article the following is written: ...
0
votes
1answer
48 views

Calculating unit wheeling

The user clicks a unit to select it for a move. Its going to move to wherever they click next. It's centre c is point cf They then click a point it is to move to. This is to be where the unit centre ...
0
votes
1answer
25 views

Categorize contact & overlap cases for 2D & 3D axis-aligned bounding boxes

My question is similar to this one. I want to determine whether two axis-aligned boxes are not only intersecting, but if they are intersecting and just touching on one edge or face, or if they are ...
0
votes
0answers
15 views

Speed after an angled collision?

I can calculate the speed when there is no angle, but I can't calculate the speed when it is angle. Physics paramaters: ...
3
votes
1answer
140 views

Why when I do an isometric projection do I get a “dimmetric” view?

First of all I would like to apologize for my poor English. It is not my native language. I have some doubts about isometric projection that perhaps I do not know how to describe them and I would ...
0
votes
1answer
91 views

Calculating price increases in a virtual economy

I'm trying to design a method to have price increase depending on the number of items bought from shops in my game. I'm fairly new to coding and I am struggling to figure out how to program the ...
0
votes
1answer
34 views

Mathf.Round returning wrong values

I want to check if the Y position is changing or not for the player and the enemy. If it has changed in the frame I want it to return true and if it didn't I want ...
2
votes
0answers
28 views

How to apply a color transform to textures when using pre-multiplied alpha?

I'm trying to apply a color map to my textures. The map is a 4x4 matrix that adjusts the contribution of each RGBA channel returned from the fragment shader. My texture needs to use pre-multiplied ...
0
votes
1answer
37 views

How to sort scores and assign positions based on the scores?

I have three game objects each with an individual score. I was wondering how I should go about sorting these scores in ascending order. I want to also give these objects a position based on their ...
0
votes
1answer
37 views

How to make controlled exchanges in an online-game?

There is an online game in which you can collect things of different values: ordinary, epic, legendary. The cheapest things are ordinary, the more expensive are epic, and the most expensive are ...
1
vote
1answer
42 views

How do you draw a random irregular polygon in java? (Asteroids)

I am coding an Asteroids game in Java. In the real arcade game, asteroids are made of irregular shapes like this: When I code, I can only set asteroids to 1 or another specific shape, like this: ...
0
votes
1answer
81 views

Bouncing Ball in c++

Background I've been making my own game from scratch. I've made my own collision system and there's a situation I'm having an issue with. Problem Pictured: a ball going in one direction and ...
1
vote
1answer
35 views

Calculation of perpendicular distance to camera plane explanation

I am following this tutorial for a Wolfenstein 3D engine. https://lodev.org/cgtutor/raycasting.html Here is the relevant image from the tutorial: I cannot figure out how dividing by rayDirX or ...
0
votes
0answers
38 views

Is there an easy way to calculate the velocity of an object on a pendulum?

Want to have a rope travel to the mouse on m2 click and then act as the pivot of a pendulum, with the player being the bob. Used some math I don’t really understand to get the angle of the mouse ...
2
votes
1answer
107 views

How to determine the cost of new units

Suppose I design a game such as Battle of Wesnoth, where there are many races, each of which with many types of units. Is there any rule-of-thumb for determining how much each unit should cost? One ...
0
votes
0answers
26 views

Finding the site of the potential collision between 2 vehicles

I've been trying to implement the unaligned collision avoidance steering behavior. I get what needs to be done on a high level, but struggle with the maths behind it. On Craig Reynolds site, he ...
0
votes
2answers
66 views

How does lookAt matrix math work?

Can someone provide me an explanation of how the lookAt matrix works? ...
0
votes
2answers
83 views

What is Unity Quaternion range?

I've read somewhere that a Quaternion in Unity ranges between [-1,1] values. I mean the individual XYZW values. Ex: new Quaternion(.1f,.2f,-.3f,-.4f) Is this true? More clearly: I know they take ...
0
votes
0answers
143 views

intersection of primitive in a unit wrapping 3D space

is there people good enough for a math problem (for a shader)? I want to write an algorithm that would intersect primitives (triangles, squares, circle, sphere, cube, cylinder) inside a unit wrapping ...
1
vote
1answer
38 views

How to calculate plane corner vertices from plane origin point and plane normal?

I have an origin point, and normal vector of a 3D plane. I want to calculate 4 vertices to use as the corners of a 2 triangle quad to render the plane.
0
votes
1answer
56 views

Simplifying Camera Strafing

I have a camera that follows the position and direction of the player. These are updated using spin and velocity. The velocity is updated like so: ...
1
vote
1answer
43 views

Calculating 3D character movement based on YAW and Pitch

I'm not sure how to calculate an XYZ immediately to my characters left based on the direction they are facing. I am learning to create a 3D game in Monogame on top of .Net Core 3.1 in c# using ...
0
votes
1answer
59 views

Confused about why my projection matrix works

My projection matrix was buggy, I'm not great at mathematics, but I checked it against the the songho tutorial, and the broken one seems correct to me but switching nearplane to farplane seems to ...
0
votes
1answer
32 views

Finding rotation quaternion from orthonormal basis?

Given three 3D unit vectors \$a\$, \$b\$, \$c\$ such that: \$a \times b = c\$ \$b \times c = a\$ \$c \times a = b\$ (ie \$a, b, c\$ form an orthonormal basis) How do we calculate a unit ...
1
vote
1answer
223 views

What are spline input keys?

There isn't a really adequate explanation of these anywhere on the internet, so I thought I'd ask this question here. What are spline input keys in Unreal? How are they represented in Unreal? Also: ...
1
vote
1answer
80 views

How to apply linear drag to a velocity vector?

I have built my own movement code for my character as I want to make smooth movement. (This project is just a character and a floor/wall for testing). The code seems to work fine, but I of course ...
0
votes
0answers
100 views

How do I prevent camera jitter when rotating the player - Unreal?

This is a problem that seems to have no reasonable answer anywhere around, yet is a commonly needed aspect of developing game mechanics. Context I'm developing a traditional 3rd person character ...
1
vote
2answers
33 views

How to get chunks in a sphere rather than cuboid

I have a chunk system to load stars around the player. It takes a given "real" loading range (aka Unity-units of range), calculates the necessary chunk loading range (as integer), creates star ...
52
votes
4answers
9k views

How are imaginary numbers useful in video game creation?

I learned about imaginary numbers in school and they seemed so impractical, so I asked my teacher what they were used for and he said "video game creation". I just want to know if this is true and ...
0
votes
0answers
26 views

Understanding Parametric UV's?

I've watched a video on Parametric UV's but I cannot understand how to calculate, the Parametric UV's on a flat surface or a sphere. Should I perceive Parametric UV's the same way as a UV map, which ...
0
votes
0answers
9 views

How to fix roll in FPS camera when looking sideways [duplicate]

I am trying to calculate the rotation for an FPS camera. My closest attempt was to create a some Euler angles(from input) and multiply that with the view matrix, this works, but only if I am looking ...
1
vote
1answer
327 views

The view matrix finally explained

I must say that I am really confused by how a view matrix is constructed and works. First, there are 3 terms: view matrix, lookat matrix, and camera transformation matrix. Are those 3 the same, or ...
0
votes
1answer
40 views

Knockback to zone on non-rectangular field

I have a playing field which is divided in 4 zones (as seen on the image below) The player (blue) is on the second zone while there are 2 enemies (red) on the third zone. When the player throws an ...

1
2 3 4 5
34