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

How do I calculate to and from a Non-Linear Acceleration?

I am looking at non-linear accelerations using the following values: initial_acceleration time_to_max_velocity max_velocity current_velocity Initial_acceleration is the per frame acceleration we ...
0
votes
1answer
25 views

Isometric tiles on wrong positions if the mouse points at a negative world coordinate

I am using this approach: http://clintbellanger.net/articles/isometric_math/ Basically, you can calculate the iso coordinates based on the screen coordinates. What I am doing is, getting the actual ...
2
votes
1answer
24 views

Find projectile initial velocity, and air time, given projectile elevation, distance, angle

I have a target X position (D). I have a turret Y elevation (E). Turret is always pointed at 45 degrees (A). I need to calculate the initial projectile velocity required to hit the target, with an ...
0
votes
1answer
23 views

How to rotate velocity Vector3 to always point the same direction so that it can be applied to 2d blendtree?

Given two variables, a Vector3 representing body velocity and a Quaternion representing body's local rotation, how could I normalize the velocity vector so that it's always oriented towards the ...
0
votes
1answer
47 views

Getting angle from current position and next position

I am using pathfinding to move a train along rails, but I need the train to rotate. I have the next intended position and the current position at my disposal, how would I go about this? Pseudocode ...
0
votes
1answer
89 views

How to make good combinations of xp tables and xp rewards?

Is there a known step by step (automatable) to define mean xp reward formula/table to bases specific challenges rewards (generically, not only defeating enemies) and total xp table that set character ...
0
votes
0answers
27 views

How to make a dynamic frontline system for my game?

My problem: Basically the units, units meaning soldiers or vehicles, influence the frontline by moving into the opponents territory (See example image). I'm trying to understand where to even start ...
0
votes
0answers
22 views

Why does this order of Quaternion multiplication not introduce roll into my fps-style character controller?

I'm working on an OpenGL based project (in C#), employing Quaternions to rotate my camera I first tried to: ...
0
votes
0answers
37 views

C++ Help with Separating Axis Theorem

I am trying to detect collision between two triangles using Separating Axis Theorem however I am unaware what is wrong with my code. The CollisionHelper::isTriangleIntersectingTriangle is called every ...
1
vote
1answer
37 views

Using enemy, player and gun position can player shoot enemy?

I was asked this question in an interview last week and I've been thinking about it but I'm unsure how to solve it. You are on a spaceship and want to shoot the enemy space ship. You have the enemy ...
0
votes
0answers
16 views

Formula to calculate Level and Current Experience from Total Xp [duplicate]

So I'm building a mobile game where I have simple XP progression system that goes like this: Level1: 0-399 Total XP Level2: 400-1199 Total XP Level3: 1200-2399 Total XP So basically for the first ...
0
votes
0answers
25 views

Upside down ground correction?

How would you go about making ground correction for a platformer but upside down(reversed gravity)? I used this formula: P.Y+=(P.Y-2)%8-1 but the character just ...
0
votes
0answers
23 views

Formula for displacement in a straight-line racing animation

I am making an animation of a race on a straight-line track (e.g. 100 m sprint, horse race, etc.). The results of the race are known in advance; all I need to do is animate the race. I am trying to ...
0
votes
2answers
122 views

How to check if two normals/directions “look at” each other?

I need to flip polygons in my application. How do I determine if two vectors face each other, like in the second image below? Note that the origin of the vectors is also important, in addition to the ...
0
votes
1answer
51 views

Getting points inside a circle with a given radius in a 2D array?

Let's say you have a system that removes everything within a square made up of 4 position points. This square is calculated by taking the center point and adding or subtracting the range from this ...
0
votes
2answers
25 views

Math: determining a proper procedural vector for sine-movement

My Problem Suppose you have an object moving along the x-axis, wobbling up and down. Movement code might look like this: x += 1; y = Sin(x); Move((x,y) * speed); ...
2
votes
1answer
48 views

How to predict where the soccer ball should be intercepted by an AI player after being kicked?

This question has been asked many times before, but most of the answers give solution to the problem where ball (target) is assumed to be moving at a constant velocity. In my scenario, I'm making a ...
0
votes
0answers
23 views

Calculate the starting position of a turning aircraft with inertial force to make it stop at desired position and heading

Continued from the answer here, I have some problem when the aircraft in my game has inertial forces after going forward and turning itself. To illustrate, from the following image (https://imgur.com/...
3
votes
0answers
82 views

Calculate the aircraft's movement path in which its side speed is required

I am working on an implementation problem in which given an aircraft and the objective of the system is to find the quickest route (optimal in terms of time) from point A (contains the information of ...
2
votes
1answer
50 views

Godot - Offscreen Target Indicator

I have a crosshair image that will lock onto enemies that are visible in the camera and will stay on the edge of the screen when the enemy is offscreen. This works until you face more than 90º away ...
2
votes
1answer
81 views

Rotate Object in world space - Raytracing

I’m programming a C raytracing project. I’ve been wanting to implement object rotations (square, cylinder) for several days but I can’t do it. For each object I have its position (x, y, z) in the ...
1
vote
1answer
79 views

Damage-calculating formula for turn-based RPG with a twist: I have developed a formula, do you the experts think it will scale up successfully?

I’m developing a turn-based combat system for an RPG. It’s a little different to your standard RPG though. The idea being, the faster the player solves the problem they are presented with each time it'...
0
votes
2answers
26 views

Getting the edge-cells in a list of cells on a 2d grid, and knowing which neighbor is missing

I create a "circle" on my 2d-grid using this code: ...
2
votes
1answer
66 views

Diamond shaped map: converting tile number to coordinates and back

I have a diamond shaped map that is displayed as follows: ...
2
votes
2answers
205 views

LibGDX Efficient way to reduce a vector's value gradually until it reaches 0,0

I can manage to achieve this but the code seems to be much longer than it should be. Velocity is given an initial value, either positive or negative and then is ...
1
vote
0answers
57 views

My arcball camera does a roll when it shouldnt be

I am trying to build an arcball camera and it's mostly working, the problem is that as you rotate around the object you have selected (orbit_target_pos in the code),...
0
votes
0answers
65 views

Trying to 'stamp' an arbitrary assortment of pixels to a texture2d that may be rotated at an arbitrary angle

This one is hard to explain but I'll try to not to overcomplicate it. Engine is Unity, for reference. I have a system where an object has a 2d texture to display a custom splat map. The user can '...
2
votes
1answer
77 views

Clamp quaternion relative to plane normal

How would one be able to clamp a quaternion based on the angle relative to a plane surface (defined by a normal)? My diagram below provides more of a visual explanation of exactly what I am talking ...
3
votes
1answer
87 views

Rotate quaternion around plane normal

How can one rotate a quaternion so that the rotation is around a plane normal? A graphic/diagram I made below gives more detail about what exactly I am implying. Note that the tip of the quaternions ...
0
votes
1answer
41 views

(Unity3D) Determine If Ray Intersects Given Rectangle

I'm building a city generator for my game and I want to ensure buildings are never placed in such a way that they overlap roads. Currently I have the system build the roads, then place buildings ...
0
votes
1answer
75 views

Need Help Figuring Out Damage Calculations for Diablo RPG Clone

I'm building a Diablo clone using Unreal Engine 4 and have been having trouble wrapping my head around how the combat calculations should work. I copied a lot of the core stats from the original ...
0
votes
0answers
17 views

tilemap movement bounderies

My active tilemap surface is 5x5 tiles, and I try to limit the player's movement inside this area with the following code: ...
0
votes
0answers
38 views

Advice for a table top rpg with rpg systems

English isn't my first language so sorry in advanced for odd wording. Idk if this is the right type of form but,I would like to make a game much Like D&D. With that said basic attacks seem to ...
0
votes
0answers
13 views

Spawning objects inside rectangle JS

I'm making a JS game "Monopoly", where I spawning players in random position inside a rectangle. I need a formula that spawns circles INSIDE a rectangle, without being outside. Here what I have tried:...
0
votes
1answer
38 views

Is it possible to work out rotate in degrees per second based on this rotate logic?

I have this code to rotate an object towards another at a given speed. ...
0
votes
1answer
28 views

Rotating projectile in direction it is moving

I am using a parabola curve to launch my arrows: ...
0
votes
0answers
28 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
23 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
48 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
98 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
43 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
36 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
32 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
25 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
26 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
24 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
593 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
46 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
38 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
17 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 ...

1
2 3 4 5
35