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
1
vote
1answer
38 views

Dividing amount of exp between rank A and B into a curve?

In my game I have a rank system. You start at rank A, and then you can level from level 1 to level 10. When you reach level 10, you get promoted to rank B, and you go from level 1 to 10 again, and ...
0
votes
0answers
28 views

Unity3d - Tile-based "Slippy" map rendered on a sphere (earth)

Scenario I'm creating a spherical version of a slippy map using osm tiles and my luck has been limited thus far. I'm starting to think my strategy has lead me astray and that I need to start from ...
1
vote
1answer
32 views

Snap joystick value to minimum magnitude when it falls below

I got a joystick displayed in the image below with range -1 to 1. Green area is 80% of the total circle and yellow area is 20%. I want to get corrected values for both areas. For example: If given ...
0
votes
1answer
29 views

How do I calculate a matrix to render a mirror about a plane using GLM?

I've been trying to work out how to render a mirror for a while now, but a lot of resources I find either use very outdated tools I'm not familiar with, appear to be college slides referencing other ...
0
votes
0answers
22 views

How do you come up with formula, balancing and state management? [closed]

Let's look at a game with lots of stats and modifiers: If you are starving, you move slower; If you are inspired, you do more ...
0
votes
1answer
73 views

Math formula for: the higher the stress, the higher the difficulty

My game has a stat called Stress, and the player has some missions to do. Each mission has a computed stat called Difficulty ...
0
votes
1answer
25 views

Compass objective indicator points towards wrong direction

I have a compass that is pointing towards player forward direction. ...
0
votes
2answers
114 views

Quaternions distorting object in Metal

I've been trying to get rotations with quaternions to work for a while now, and I feel I am very close to it actually working but I just can't get it to work. I do not have a view matrix yet and am ...
1
vote
1answer
43 views

Find the smallest angle to turn between two angles in range 0..1

I have a function for approaching a value to a target by a certain amount: ...
1
vote
1answer
78 views

What kind of math is used by this camera panning script?

I'm not fluent in English so I apologize in advance. I have found a source code in order to pan camera by touch - here it is: ...
0
votes
0answers
22 views

Dynamic circular motion increases in energy

I am experimenting with designs for physics engines for which I use particles and fields like magnet fields. In magnet fields you have a thing called Lorentz force ...
1
vote
1answer
55 views

Isometric projection, calculate camera angle for specific tile height

I'm experimenting with different tile dimensions while rendering 3D assets for an isometric game (or dimetric to be exact). Everyone does a 2:1 ratio so the tiles in isometric view are 256wx128h, ...
0
votes
0answers
69 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
1answer
68 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
49 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
114 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
77 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
75 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
42 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
99 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
29 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
64 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
28 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
22 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
42 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
63 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
47 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
100 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
14 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
65 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
222 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
53 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 ...
2
votes
2answers
96 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
54 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
52 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
16 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
54 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
81 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
32 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
86 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
46 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
132 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
18 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
91 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
44 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
2 3 4 5
37