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

Unity3d: Get a direction vector parallel to plane

I need to send a raycast from my camera which is parallel to the plane (Ground) and in the same direction of its forward vector (Represented by the black color vector) I cant use world space ...
4
votes
1answer
58 views

Calculating damage with damage mitigation/amplification curve/function

Let's say instance A is attacking instance B for N damage. I want to calculate the ideally expected damage if those instances have damage mitigation/amplification depending on target's current HP. ...
1
vote
1answer
35 views

How to ensure my Sine Wave movement starts from the middle-line of the wave

I am trying to make an enemy for a space game which has Sine style movement. I pretty much have it working how I want, but right now I have to manually fiddle with the 't' value to make the wave ...
1
vote
2answers
46 views

Calculate position given velocity and acceleration at a given timestep

I am following a Pixar course at Khan Academy and I came across a simulation of a double spring with a given timestep. I understand how it works and why it behaves the way it does, but I want to know ...
1
vote
1answer
38 views

Wobble the y(up) axis of a circle

I wrote a script that moves a game object(w/ trail render) in a circular motion via the sin/cos functions ...
0
votes
1answer
16 views

SmothStop Function doesn't work as expected

i'm trying to create a smothstop function i need it to control time variable on my lerp function used to move character and so on...what i have is this ...
0
votes
1answer
56 views

How to calculate score in my game based on playtime and coins picked?

I've been trying to figure out a way to calculate the score in my game.... but nothing seems to work properly... The score is to be calculated according to: playtime coins collected. The playtime ...
1
vote
1answer
35 views

Find angle (slope) of collision plane?

I have implemented a collision and response system based on the famous "Improved Collision detection and Response" paper. However I'm having an issue with objects sliding backwards on slopes. I ...
0
votes
1answer
102 views

Two Points Rotating Around Circle?

Currently I am working on a 2D game just like duet game, it is my first game (Unity 2D). When I press left key both points rotate fine. But when I press right, the points are not rotated. So my ...
0
votes
0answers
43 views

Reconstruct world position from depth

I am trying to restore the position from the depths. I separately created a position map in view space, which I use as a basis for tests. But I can not get the same result when I try to reconstruct ...
0
votes
1answer
44 views

if rotation < -45 && > -140 issue

I have a problem with this if statement. If the rotation is < -45. And > -140 Then this statement would be true when the rotation is = -90? And it would be false if the rotation is = -170? I'm ...
0
votes
0answers
12 views

How to implement Meshlab's rotation manipulator? [duplicate]

I want to implement a rotation handle/manipulator mechanism that would enable user to rotate a 3D model exactly like Meshlab does. Unfortunately I don't fully understand how does the rotation gizmo ...
0
votes
1answer
69 views

Predict Time of projectile flight

I am trying to matemathically predict how long will projectile fly until it reach the target. I am trying to implement this formula: t = [V * sin(α) + √(V * sin(α))² + 2 * g * h)] / g where I know ...
0
votes
0answers
33 views

The X axis becomes the Y axis after a quaternion rotation

I am making a FPS game, and I have a for loop where I place out "ground" objects. (pseudo code) ...
1
vote
1answer
55 views

rotation matrix problems - opengl and own types

In an effort to learn things deeper I'm writing my own mathematics for the first time instead of using libraries. As far as I can tell my matrix multiplication is correct, and translation and scaling ...
0
votes
0answers
28 views

libGDX - Zooming on a specific point in 2D space

I was hoping to modify my game so zooming would focus on a point: the mouse location on desktop or the midpoint between two fingers on mobile. This appears to require a simultaneous zoom and translate....
0
votes
2answers
109 views
0
votes
1answer
45 views

Capsule to Sphere Collision

For my Maths unit at university, we have to manually calculate if a sphere is colliding with a capsule collider. The information I have to go with is this; You have the following Sphere: LadyBird3 -...
0
votes
0answers
28 views

Yaw on a spherical world

I am trying to make a game where the player can walk along the surface of a spherical planet, and am not sure how to handle orientation. Pitch is relatively easy, as it is simply how much "above" or "...
0
votes
0answers
30 views

How to move an object in a heart shape pattern in javascript?

How can I move an object in a heart shaped pattern? I have a move(x, y) function that I can use to move the object, but how to I make a function that will move the object in a heart shaped pattern, ...
0
votes
1answer
74 views

How to compute the moves amount in a match-3 game?

I have a match-3 mobile game, similar to these popular games in the store. Mechanics are different, but the gameplay stays the same: NxN board X moves Y objectives to complete to win tons of ...
0
votes
0answers
21 views

Divide screen in eight sectors [duplicate]

Currently in our game we use a 4 directional movement. Some abilities are triggered on mouse click and "fired" in the direction the player has clicked. For this, I have split the screen in 4 sectors (...
0
votes
0answers
16 views

Moving and rotating object with another object [duplicate]

Sorry i bad painter)) Need move and rotate 'OBJECT №2' with 'OBJECT №1' I have origin point(also rotation point) and angles of two object. (Also min and max coordinates of these objects) Vector ...
0
votes
0answers
59 views

Quaternion Rotation after performing previous rotations

Have Quaternion \$ Q\$ which is rotated on the \$X\$ axis 90 degrees. \$Q\$ is now \$ (0.707106, 0.707106, 0, 0)\$. I want to rotate \$Q\$ another ...
0
votes
2answers
88 views

A* GetNearest() implementation

I'm trying to implement pathfinding in my platformer and I'm having trouble coming up with a way to find the nearest node to a world point. I tried this: ...
1
vote
1answer
49 views

An algorithm to make one object follow another on a 2D grid

I am using Greenfoot, but this can apply to pretty much any 2D engine. So my question is a basic one that I somehow couldn't find an answer to already. Basically, if I have an enemy and the player, ...
0
votes
2answers
43 views

How to implement this XP formula?

I found this response but the thread is closed: https://gamedev.stackexchange.com/a/13639 level = constant * sqrt(XP) I seem unable to properly get current level, this is how I tried to do it, and ...
0
votes
1answer
36 views

Movement velocity relative to a static object (Vector Maths)

I have a static object. I have a moving player. If the player is moving directly towards the object then I want to return the value of 1. If the player is moving directly away from the the object ...
0
votes
1answer
43 views

Algorithm for finding edge vertex points on a tilemap

I have a 2d tilemap array contains 1 or 0. 0 corresponds empty tile, 1 corresponds solid tile. If tile is 1 I draw a texture. I have to find edge vertices and coordinates that 1's grouped. I couldn'...
0
votes
0answers
29 views

Rotate a Vector by Quaternions

I'm trying how to work out how to Rotate a Vertex using Quaternions, using a scientific calculator, or on paper. Exam preparation. My lecturer has given us this; Quaternion = (-0.5, 0, -0.7071067, 0....
2
votes
1answer
54 views

How would I rotate my billboards parallel to the camera view?

I'm trying to make my own space-sim in Godot and I'm stuck trying to get the visuals of the "starfield"-effect that is a staple of the genre. I'm using a Particle system with billboards that would be ...
0
votes
1answer
23 views

How can spotlights be implemented with a perspective projection?

I was reading Shadow Mapping with Directional Lights and noted that spotlights are implemented by rendering with the perspective projection, stating that the spotlight worked just like the camera. ...
0
votes
1answer
50 views

2D vehicle collision detection and rotation

I'm attempting to make a simple 2D car game from scratch, but I can't figure out the collision detection between a vehicle and a road. The vehicle should also rotate appropriately to its position on ...
2
votes
1answer
74 views

Math needed to create a very simple 2D side view car game

I'm trying to create a 2D side view car game (something like Hill Climb Racing, but much more simpler), but I'm confused on the math and physics. Most of the tutorials I found were about making a top-...
0
votes
1answer
72 views

Understanding the “gradient” in Perlin Noise

If I didn't get it wrong from the wikipedia, the word "gradient" should represents either the derivative for continuous functions, or the differential for discrete functions. To rebuild the original ...
0
votes
1answer
21 views

How to scale a sprite on x axis to touch the point without changing pivot?

I have a sprite. The pivot is at random point. I want to increase the sprite's scale on the x axis, without moving the pivot, until its edge touches a point at right. I have a method to set/add size....
1
vote
1answer
52 views
0
votes
1answer
28 views

Rotating on a slanted surface?

I want to rotate (change it's yaw) an object when its sitting on slanted ground. Pretty much I want to rotate around the ground's normal. Right now I ray cast down, get the ground's normal. Then I do:...
1
vote
0answers
30 views

Circle ceases to be a circle when radius is below a certain value

I'm using the LineRenderer component to draw a circle. It renders fine, but it's a little too large. The smallest I can set the radius is .06f. If I try to set the radius to anything less than that, ...
2
votes
2answers
62 views

Midpoint displacement generating unsatisfactory terrain

Following this lesson for implementing mid-point displacement algorithm for terrain generation. I aim at generating a wavefront(obj) file of the terrain I have an array of dimension (2^n + 1) x (2^n +...
1
vote
1answer
58 views

Algorithms for Automated Game Levels Creation ( 2D )?

I am trying to algorithmically create a game like the one in the picture below I am trying to Create random levels from an algorithm. Ideally, the algorithm will take into account the desired ...
0
votes
0answers
21 views

From look-at vectors to a quaternion

So, I have code to create a quaternion from a matrix (using the 3x3 rotational part.) And I have code to construct a transformation matrix from a lookat + up vector pair. To go from lookat+up to ...
0
votes
1answer
40 views

How to get the tangent and normal of a collision?

In my game, one of my objects casts a ray into a 2d space. If that ray were to hit another object, I'd like to draw a line that is perpendicular to the tangent of the ray's hit point. So when the ray ...
3
votes
1answer
155 views

Octahedral impostors, Octahedral mapping

I'm facing some issues understanding this article about octahedral impostors. More specifically I quite don't understand how one can map the hemi-octahedron (subdivided) vertices to texture ...
0
votes
2answers
42 views

How to calculate turret position after rotation

I'm trying to make a tank character for my game but I couldn't do the math of firing bullets from turret instead of center of the tank. I tried some Stack Overflow solutions but I couldn't understand ...
1
vote
0answers
61 views

algorithm to change the center of the image

I need and algorithm in Java if possible to change the center of the image when scaling.What is happening to me is represented in the first image: when I scale the image the image scale according to ...
0
votes
0answers
25 views

creating levelup stats based on curves [duplicate]

I'm creating a simple level-up system and I'm looking to base the stats gain on curves so I can tweak them easier, I know it's a math function, but I have no idea what to search for. I need to create ...
0
votes
0answers
33 views

XMMATRIX performance

Dears, I am facing a performance problem when I try to access cell 42 and 43 in XMMATRIX define in DirectXMath.h. The frames dropped by 100 FPS. Here is my code: ...
0
votes
0answers
49 views

Get Position and percentage of a given point on a Spline

I have a spline data, in a List chunkPath; and a player position (x, y, z). I would like to get the closest point in the path, and get the actual percentage we are inside the path... So What I have: ...
6
votes
0answers
120 views

How to move a portion of bezier/spline curve along its complete bezier/spline curve?

Based on the image below, I have a curve (orange) which is a bezier sub-curve of an original curve (longer black curve). The original curve consists of a number of cubic bezier curves joined together. ...