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
43 views

What would be the effect of making Wealth a diminishing-returns variable?

I've been playing a bunch of Fallen London lately, and I find it interesting how they do "pyramid qualities": Achieving level X in something requires +X points.. 1 for level 1, 2 more for ...
0
votes
0answers
35 views

Find those points lying on a circle from a ton of points

Given a 2d scene and 10,000 players with coordinates in the scene, I want to implement a function, the input is a circle with the center coords and its radius, the output is those players that lie on ...
0
votes
1answer
39 views

How to compute an incremental movement: \$f(t+h)-f(t)\$ or \$f(t)-f(t-h)\$?

For the sake of getting precise position, I think I need you to clarify whether or not the tutorial calculation is incorrect and my calculation is correct. Assume we want to move an Actor up and down ...
1
vote
2answers
99 views

Formula for stacking percentages to keep them from getting out of control

I have a game that has a mechanic, where a specific class can stack what are called "life stealing enchantments" to steal greater amounts of health from the enemy depending on the type of ...
0
votes
1answer
69 views

Could you explain how this GameObject rotating around another GameObject works?

I'm just learning Unity and I follow a tutorial for a simple game which I want to build up from. I'm already mostly done with the course and at the end a "boss enemy" gets implemented. Its ...
0
votes
1answer
65 views

Calculating child world translation, rotation and scale

I'd like to know if it's possible to calculate a child's world translation, rotation and scale individually. I'm used to seeing devs resorting to matrix multiplication and then decomposition, like so: ...
0
votes
1answer
33 views

How do I predict where a player will be next in Forge/MCP?

I am trying to predict where a player will be next based on where they are now in Java. I have their XYZ position, their XYZ motion, but I don't have their speed. How can I predict where they will be ...
0
votes
1answer
65 views

Java Simple 2D Grid Pathfinding

I want to code some basic pathfinding for my bot in Java. Below is a 2D grid representation of the 3D world. 0s being the places you can go, and 1s being the places that you cannot go. ...
0
votes
0answers
26 views

How to find player movement speed in Forge/MCP?

I want to predict where a player will be next based on where they are now. I have access to their XYZ, their motion in each direction, but I don't know how fast they are moving. Let's say that the ...
-1
votes
1answer
52 views

How to gradually interpolate smoothly between two yaw rotations in Minecraft MCP/Forge?

I am coding a custom client for Minecraft using MCP. (Please no hate, I'm not making a hacked client!) I have two variables currentYaw which is the current yaw ...
0
votes
1answer
24 views

How to find Particle Position at Time with velocity and friction?

I have a Particle p. A particle consists of a start position p0,an age t, a velocity ...
0
votes
1answer
32 views

Arranging points in a 2D grid so that successively added points approximate a square shape

So, I ran into a problem with placing points in a grid while always trying to fit them into a square. Here are some examples (the numbers represent the order of placement): Placing 1 point: ...
0
votes
0answers
21 views

Unity: how to make a kinematic rigidbody react to a rigidbody hitting it?

How do I make a non-kinematic rigidbody react to a "normal" rigidbody colliding with it in Unity? Like when the rigidbody hits the non-kinematic one, it pushes it back (note: not using the ...
0
votes
1answer
44 views

using a starting and ending point, how can i find how far in-between those two points a third point is?

quick diagram to explain what i mean. i have a start and an end, the third point can be anywhere in space, but i need to calculate from 0-1 how far they are in-between these two points. The points are ...
-1
votes
1answer
38 views

How to get the up direction given a point and rotation

TLDR: I'm asking for the direction of the up vector of an entity that can rotate in JavaScript that has a x, y, and ...
0
votes
1answer
62 views

How to tile a texture

I'm creating a simple program in C# and now i'm trying to slice an image into multiple tiles similar to a grid pattern so it does not get stretched when drawing to different resolutions. What i'm ...
0
votes
1answer
30 views

2d zooming function using transformation matrix

I'm trying to create a sort of "graphing calculator coordinate system" where you can zoom into a point by scrolling with the mouse wheel. I'm using javafx's transformation matrices (Affines) ...
-1
votes
1answer
64 views

How to calculate speed of a moving object in unity

Currently I am trying to calculate the speed of an object here is the below code snippet: ...
0
votes
0answers
12 views

How to find the center of mass from CapsuleCast in unity

Is there an easy way to find the center of mass from a CapsuleCast, or should I find the geometric center of it?
0
votes
0answers
79 views

How to implement texture slicing

I'm making a simple game in C# and i'm trying to slice my UI images into 9 smaller rectangles, so the image doesn't get stretched when drawing to different resolutions, but i'm having lots of problems ...
0
votes
0answers
13 views

Orthographic camera clip the model when Panned with mouse

I am dragging the camera (point Of View) of scene. I am using orthographic projection Problem I am facing is suppose the camera is not rotated then I can drag the camera and it is working fine , But ...
3
votes
0answers
63 views

Approximate doom/heretic-style freelook distortion with modern graphics APIs

Currently working on a doom-like engine with fewer technical limitations, and looking into rendering techniques. I'm aware doom's a raycaster, and I want to capture a similar look but with modern ...
3
votes
2answers
216 views

How do you encourage players to do hard things?

I'm working on an app that teaches real-life skills by pitting players against each other to compete in skill improvement tasks. The problem is, players have a number of different tasks they're ...
0
votes
1answer
34 views

Pygame : problem with calculating an angle between two points

I've been struggling to calculate the angle alpha between an object and a certain point M so that I can move that object to M. To calculate alpha, I'm using ...
-1
votes
0answers
22 views

implementation of a b-spline curve n points

hi i'm trying to implement the n points spline curve, but it seems like it requires some calculus knowledge. Unfortunately I did not follow the calculation of high school. I would like a function that ...
2
votes
2answers
95 views

How to orient a rectangular object, so when a sphere ( ball ) collision happens to redirect it towards a point?

I have a rectangular object and a ball ( sphere ) in 3D and would like to orient the rectangular object in such way that when a collision with the ball and the object happens, to redirect the ball ...
-1
votes
1answer
53 views

Move two sprites together with offset?

I'm making a simple game in C# for practice and i'm having some problems when dragging a sprite and making another sprite follow it. What i'm trying to achieve: When dragging a sprite, i want ...
0
votes
0answers
10 views

Move sprite in relation to parent? [duplicate]

I'm writing a simple game in C# and i'm having some difficulty to calculate the local position of a sprite. What i'm aiming to achieve: Calculate the sprite "local position" relative to the ...
0
votes
1answer
46 views

How to keep objects in the same position relative to their parent?

I'm writing a simple game in C# and i'm having some difficulty to calculate the local position of a sprite. What i'm aiming to achieve: Calculate the sprite "local position" relative to the ...
0
votes
0answers
15 views

Update the positions of child objects of a scroll bar when its parent moves?

I'm implementing a vertical scrollbar for a small game project and I'm having some issues with calculating correct positions of the scrollbar controls when its parent control moves. At the moment, ...
1
vote
1answer
53 views

How to draw splatter (one color) on 2D grid to cover approximate number of pixels? (looking for algorithm/math answers)

Imagine a 2D grid, where water stain increasing because of water drops. But not in plain circular way but more like noisy-splatter way. Or like corruption way. I want to create effect that will ...
1
vote
1answer
71 views

How to implement a simple Scrollbar

I'm making a simple UI system for a small game and i'm having some difficulty to implement a Scrollbar. At the moment i'm having two major problems that i need some help to solve: . Calculating the &...
1
vote
1answer
28 views

Space torque semi-independent of center of mass

I am making a 2d user build spaceship game that allows the user to place thrusters where they would like. I've read a bunch of posts in a lot of places including stack exchange on how determine the ...
0
votes
1answer
84 views

How can I create this springy oscillating motion chasing / orbiting the mouse?

I'm trying to recreate this motion, I think most of the motion is based on this formula \begin{eqnarray} x(t) &=& A e^{-\gamma t/2} \cos(\omega t - \phi) \\ y(t) &=& B e^{-\gamma t/2} ...
0
votes
0answers
44 views

How do I replicate this camera effect?

I am trying to re-construct the camera logic of RE4 that is applied when the player aims a gun. I have attached a hack to RE4 which enables the user to change the camera's FOV. Because of that I ...
0
votes
3answers
125 views

Why is the derivative important in game development? How did you use it in a real scenario?

I'm really eager to know how a programmer finds useful a derivative in game development, using a real scenario as an example. Also I plan to use this question to understand the importance of ...
0
votes
1answer
17 views

Calculating view matrix from rotation, elevation and location

I have the rotation(A), elevation(B) and location(C) of a camera in a left handed 3d space. +...
0
votes
1answer
88 views

Best way to implement a to hit formula based on provided stats

There are a ton of these questions, some can get really mathy - which is fine, but I am looking for a simple way based on a few stats, I thought I came up with one, so I will share it in hopes that ...
1
vote
1answer
43 views

How to best deal with percentage from gear and skills when stacking

I have a issue I am unsure the best way to go about solving. Developing a game I store all the "percentage boosts" a character could get either from skills, equipment, quest items or whatnot ...
1
vote
0answers
47 views

Why does the clip length of an animation not match my math?

I need to re-create an existing animation. The new animation should have the same amount of frames and length and FPS. Unity shows the following for the original / existing animation: As one can see, ...
1
vote
0answers
32 views

how can I normalize the speed of a polygon moving over a series of connected quadratic bezier curves with varying lengths?

I am generating a bunch of quadratic curves that are connected together, creating an array of curves, and a function which returns the position on the curve for a given time. ...
1
vote
0answers
20 views

How can I draw a partial circle with LineRenderer?

I'm using the following code, which I found online, to draw a circle with a predefined radius centred on a predefined point in LineRenderer (2D game). ...
0
votes
0answers
58 views

How to design a system that allows for custom equations of movement?

I'm developing a top-down shooter and I currently have a PhysicsSystem which operates on TransformComponents. Basically, it ...
1
vote
1answer
63 views

Matrix math in cascade shadow mapping

I am implementing cascade shadow mapping algorithm and currently stuck with matrix transformations - my AABBs, when projected in light space are pointing in the direction opposite to the light: I was ...
2
votes
1answer
172 views

Drawing OpenGL camera frustum

I am trying to display camera frustum in my OpenGL application. I calculate the vertices of the frustum pyramid using reverse projection from screen space to world space. The camera uses perspective ...
0
votes
1answer
64 views

What happens if first we scale a rotation matrix and then multiply it with an object?

This question has been bothering me lately. I know the correct order to scale, rotate and transform a matrix but the question I have is very different. What if we first scale our rotation matrix by ...
4
votes
2answers
100 views

Can't figure out math for converting negative indices of my voxels and chunks to positives

In my voxel game, I'm trying to spawn chunks in all directions. But since my world starts at 0,0,0, some chunks can spawn at negative positions like ...
0
votes
1answer
62 views

RNG random numbers/preset payout rate contradiction

Taking a casino slot machine for example: How can the probability of a payout TRULY be random with a preset payout rate? If a casino has slots programmed to a specific rate or percentage of payout, ...
0
votes
1answer
19 views

Euler Angles of Any Great Circle from hit.point of a sphere

How do you get the Euler Angles of Euler Angles of Any Great Circle that surrounds the raycast hit.point of a sphere?
0
votes
1answer
25 views

Ray-Triangle Intersection: does the direction of the triangle normal matter?

Found an article here about ray triangle intersection: https://www.scratchapixel.com/lessons/3d-basic-rendering/ray-tracing-rendering-a-triangle/ray-triangle-intersection-geometric-solution It states ...

1
2 3 4 5
37