# Tagged Questions

A mathematical concept that can be used to express position, direction or velocity and which can simplify or outright trivialise spatial problems.

468 views

### Unity forward vector flips when upside down. Mario Galaxy style gravity, bad rotation?

This is a question that I think is best to explain visually, so I will do my best to be succinct here. What I am trying to do: Allow the player to run about a world that is spherical, not a flat ...
234 views

### How can I calculate the orthographic projection needed to encompass an object with arbitrary rotation?

So I need to set up the dimensions of a orthographic projection that will encompass the entirety of a bounding box when viewed from any arbitrary position. That's an eye (programmer art); and the ...
37 views

### Making a ordered list iterator [closed]

Noob here, I am trying to display a list of a vector with ascending numbers. To display the list I iterate through the following code. cout << "\nYour games list is: \n"; for (iter = ...
81 views

### How do I figure out if a point is infront or behind my vehicle?

I need to figure out whether a point is infront or behind my vehicle. I have the vector of it's position, forward direction. So far I have tried finding the vector perpendicular to its forward ...
98 views

### LibGDX/Java - Trying to find the vector from one object to another

I want to add springs in my game that work like the ones in sonic - i.e. if you can't get over an obstacle you have to hit a spring which sends the main character flying towards another spring that ...
353 views

### Estimate the time it takes for an object to travel from point A to point B

I have an object with vec2 position, velocity, and destination with 2 variables maxspeed and acceleration. In each step, its position is calculated as follows: vec2 desiredVel = destination - ...
102 views

### Need some help with math steering behavior stopping on destination point

I have implemented a movement system based on steering behaviors: http://gamedevelopment.tutsplus.com/series/understanding-steering-behaviors--gamedev-12732 where each object has vec2 position, ...
711 views

### Is there a quick way to determine if a vector is in a quadrant?

I am wondering if there is a quick easy way to determine if a given vector is in a specified quadrant. In the below image, I've define the ranges of the blue quadrants. For example, if I am given ...
217 views

### Vector3.Angle() Never Reaching 0

I'm having trouble understanding why with this script, Vector3.Angle() sometimes will never reach 0. This question comes from me trying to make a "turret" that rotates to face a target position. It ...
147 views

### 2D indicator for Rotation in 3D space

This is the view from my spaceship. It can move around in 3d space and turn up, down, left and right. The planet Earth on the top right is selected. Now I want to create the red arrow to always ...
2k views

### How to rotate an object to face another in Unity?

I'm having an issue where I can't seem to rotate my bullet appropriately whenever I spawn one. I currently have a capsule prefab I am testing with. I spawn it with the following code. ...
77 views

### Dragging an object and moving it back to it's original position on release?

I'm making a small game, and I'm trying to add this mechanic where if you click on an object and move it, then you release the object it will snap back to it's original position. Currently, each ...
86 views

### Pygame 2D Vector Math Mouse Input

The following code is supposed to move a player sprite (in this case it's an 8x8 red square) to the coordinates of where the mouse is clicked. I'm able to move the square in the general direction of ...
71 views

### how to determine wall direction with information of normal and incoming direction

what is formula ( and theory behind) used to determine wall direction with only knowing the normal of wall and incoming direction object. in this thread example :Collision detection - Smooth wall ...
381 views

### Controlling roll rotation when travelling along bezier curves

I am currently working on a curve implementation for use in Unity which includes an editor: The aim is to get an object to follow the path represented by the curve at a constant velocity. Currently ...
150 views

### Averaging normals, or tangents

I am using a library to load an obj but it doest compute the tangets for each vertex, which I need for normal mapping and pom. I computed my tangets, and bitangents, everything appears to be fine, but ...
865 views

### Create random polygon shapes

I want to make a random shape made out of points. I want the points to create a polygon shape. Is there a clever way to create a random shape like this? Im thinking going throug X points and giving ...
192 views

### Calculate slope for linear interpolated movement

I want to move rectangles to their targets the "smooth" way with linear interpolation. I hope this is right. float slope(float x1, float x2, float y1, float y2) { return std::abs((y2 - y1)) / std:...
49 views

### Vector magnitude in orientation

First, a quick overview of my problem: I have a game entity which has a quaternion to represent its rotation/orientation. It also has a 3D vector in world space for its linear velocity. From the ...
303 views

### Vector-based Pong-ball bounce calculations

I'm making a 2D game with pads and balls, sort of like Pong, in Unity 4.6.1. The calculations, however, won't be (very) Unity-specific. The pads are going to appear in various rotations, and therefore ...
242 views

### How do I calculate the bounce vector of a ball hitting the starting point of a segment?

I have a ball (with parameters x, y, radius) that travels on the screen (with vectors directionX directionY) and can collide with a segment with random slope (with parameters startX, startY, stopX, ...
717 views

### How can I check if a player-drawn line follows a path?

I want to draw an invisible path that the user must follow. I've stored that path as points. When a player draws a line, how can I test if it follows the path I've stored? Here's an example for ...
230 views

### Problems with Raycasting Requirements

Im working on a script which kinda works like an Enemy AI. Its kinda like a detection system with requirements that are required to be met. This is a recent question i asked using my code Raycast ...
168 views

### Raycast Flashing problem

Can anyone tell me what is wrong with me code? If you can see, whenever the player is in range of the raycast, the enemy turns red. But for some reason, even when the player has meet the requirement ...
103 views

### Direct raycasting from moving point A and moving Point B

I am attempting to raycast from Point A to Point A (both moving points). I dont understand the comcept of raycasting (direction). Update() { player = GameObject.FindGameObjectWithTag ("Player"); ...
2k views

### How do I interpret the dot product of non-normalized vectors?

I know that if you take the dot-product of two normalized vectors, you get the cosine of the angle between them. But if I take the dot-product of two non-normalized vectors (or one normalized, one ...
1k views

### How can I draw a line of certain length and direction?

I want to create a line of certain length and direction. What I mean by this is drawing a line from Point A to Point B. Normally in Unity C# to draw a line from Point A to Point B is simply: Debug....
111 views

### Rotating a 3d vector around an axis using sines and cosines

I am trying to represent a 3d cone light's direction using only 2 variables. Right now I represent it with two points (6 variables) but I know that the direction in 3d space can be represented by two ...
284 views

### How to transform Unity terrain coordinates

My map creator created some terrain in Unity, but all my scripts are based on the X-Y axis. Is there an easy and smart way to transform them into Z-Y, or do I have to change all the vector variables ...
78 views

### Draw my array at a position defined with Vector2

I'm developing a space invaders game in C# using XNA Game Studio. So I got some of the invader logic complete: An array holds the invaders and draws them on the screen, animated and moving.But I can't ...
985 views

I have the generic tessellation evaluation shader for triangles but I need to make it work for quads. Is there any chance someone could explain what is happening here and point me in the right ...
2k views

### How do I tell if my enemy can see my player?

Given a player and an enemy with position, and given the direction vector of each, how can I tell if one can "see" the other? In other words, how do I test if one position with direction is in front ...
429 views

### Aligning a gameObject to position and normal of another gameObject inside Unity

So I am instantiating a GameObject (the one with cities and trees in the image below) and trying to align it to a hex tiles on a Sphere. So after I instantiate the gameObject, I ray-cast to get it ...
1k views

### How can I pass a std::vector<Vector3f> to my shader?

I have a Vector3f type which has x, y, and z properties. I have a std::vector of these vertices which describe my terrain. I would like to pass these values to a vertex shader through a uniform ...
122 views

### How to convert non-discreate data for discreate pathfinding?

I have a list of entities that looks like [{x,y,width,height}, {x,y,width,height}, ...]. This list is non-discreate, It doesn't follow a grid. entities can be positioned at floats like x:2.345 Most ...
724 views

### c# Unity - Matrix output incorrect on vector rotation

I have a input Vector (1,1,0) when I run it through a Unity Matrix4x4 class with a rotation of 90 degrees around the Z axis the output is (-0.9999999,1,0) which is nearly correct but strange. But (2,...
683 views

### How do I make a 2D race car turn smoothly? [duplicate]

I'm making a competitive 2-player 2D racing game for a school project. I'm struggling with the movements of my car: I made it a square for testing purposes and it can move left, right, up or down, but ...
131 views

### Rotate an arrow on a plane?

I'm creating a display for a GPS-based embedded system and would like to have an arrow indicating the current bearing. I'd love the arrow to have a 3d appearance by rotating it on a plane tilted up ...
110 views

### 3d game math problem [duplicate]

i'm very much new to 3d math operations. I know how to rotate 3d points certain degrees arbitrarily by any axis but we were given a strange problem to think on. I'll spare using actual numbers on it,...
157 views

### 3D Translations relative to 3D Rotations

I'm trying to program camera movement to be relative to camera rotation. (Forward is always forward, regardless of pitch, yaw, and roll) I want to be able to move forward, backward, left, right, up, ...
104 views

### using rperp or perp to find perpendicular of a vector

i have code local coordinate Vec2 velo = Vec2(100,0); Vec2 Heading = velo.getNormalized(); Vec2 side = Heading.perp(); Vec2 trans = Vec2(12,12); then i can generate toWorldCoordinate for trans ...
31 views

### Determining if a Point3D passed another

I have 2 points A and B in 3D space (say of type Point3D). B needs to travel towards A and then stop either when it reached or passed B. The direction between the two points is known (can be easily ...
2k views

### How to calculate left/right oriented angle between two 2D vectors? [duplicate]

I would like to calculate angle between two 2D vectors. Here's a picture of what I'm trying to achieve: I have an obstacle line segment AB and incoming moving PC. If I'm coming from one side C¹D¹ ...
645 views

### Beginner: How do I calculate a vector?

I am trying to wrap my head around some concepts in a side project I'm working on. I'm struggling with how I can calculate a vector based on my character movement logic. Here are the relevant details ...
247 views

### Smooth anmiation with LibGDX

I want to move a enemy from its current position toward the mouse position in LibGDX. x, y - enemy position saveX, saveY - position where my enemy need to go(or mouse position saved at specific time)...
1k views

### Opentk LookAt() and 'eye' argument rotating

I'm trying to create rotating camera, which looks down by 45 deegre like this: However my code for rotating eye vector is not working properly and I achieve vertical rotation, when it should be ...
21 views

### get vector of enemies that facing player [duplicate]

if I have player location (4,6,-3), thee y- axis is vertical and I have enemies at (7, 6, 12), (16,6,11) and (11,6,1) how to calculate the vector of each enemies that is needed to face the player? how ...
193 views

### Explaining vector math for a pendulum camera

I came across a code that I guess is doing a pendulum camera, that's the class name. I would like to know the math behind that. I would like also to know how to decipher those stuff in game math, ...