Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [vector]

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

0
votes
1answer
19 views

Problem with Material Parameter Collection Reference Variable in Set Scalar Parameter funcion

I was following a tutorial on using GameInstance. Where the guy in the video would teach how to choose the color of the ship by clicking a button on a level (x), so as to affect the ship on another ...
0
votes
1answer
34 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
0answers
22 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....
0
votes
0answers
13 views

Transform Vector3 into Vector2 with PerspectiveFieldOfView Matrix

If I understand correctly, Matrix.CreatePerspectiveFieldOfView(…) creates a Matrix that projects a ...
0
votes
0answers
13 views

Instantiating tiles

I'm writing a game that instantiates a large gameBoard. For some reason the below code won't instantiate tiles across the Y-axis. All 10000 tiles are instantiated in a straight line across the X, and ...
0
votes
2answers
45 views

Sending a shot left/right/up/down based on directional key press

I am trying to make a top-down shooter game with similar combat to the Binding of Isaac: when I press the up key the shot goes up when I press the right key the shot goes to the right I have all ...
1
vote
1answer
29 views

How to decelerate Ship using Vector Objects in Java

I am developing an Asteroids type game in Java, using a custom Vector2D class for the Ship. I have a vector object for its position, direction and velocity. I am having an issue with the ship ...
0
votes
2answers
42 views

Having two points (line) how can I substract a specific amount to each point?

I have two points that make a line. And I need to subtract a specific amount to each point keeping the direction of the line. I know the radius which is the amount to subtract. The red dots of the ...
0
votes
2answers
43 views

How to limit speed while still adding external forces

I have a ship with a single thruster in space (no friction). My ship uses integration on every update, like this: (PSEUDO CODE) ...
0
votes
1answer
58 views

Controlling a thrustered 2D space ship with angular rotation and max speed

In my game I have a computer controlled ship that is accelerated by a thruster: with a constant force and in the direction of the ship's current orientation/rotation angle. Thrusting My ship has a ...
0
votes
1answer
32 views

Unity, Object's vectors are not rotating with the object. what did i do wrong?

I found a youtube video (Sebastian Lague: Character Creation (E07: Unity character controller)) that has a really good movement script, I understood it and used it for my character. When I started ...
1
vote
1answer
60 views

What is the value range from a dot-product between two normalized vectors?

I've recently learned about the existence of dot product and I was wanted to know how to determine the value range between two normalized vectors.
0
votes
1answer
32 views

How to determine what direction an object should orbit around another

I am creating a game in Unity with 2D. When a button is clicked a static object is attaching a hinge joint to a dynamic object, so the dynamic object orbits it. When the dynamic object gets attached, ...
1
vote
1answer
48 views

How do I find the downward sliding direction of a plane?

first time poster. I'm curious as to how I can obtain a vector that defines the downward slope of a 3D plane. The goal is to apply this to a player as a force to achieve a sliding mechanic, like in ...
0
votes
0answers
11 views

Unity: finding force vector to separate colliders in OnTriggerStay events

In Unity, I have Trigger Colliders, and catch the OnTriggerStay(Collider other) events. Once two Colliders are touching, how do I get the Force vector to make them want to separate again? In the ...
-1
votes
1answer
46 views

Replace vector3 list with object list?

In this script I respawn a group of enemies in different places. To choose those places I have to put manually position value. I need to change this with object. ...
0
votes
2answers
56 views

Find if one player is visible to the other

Two players (p1 and p2) are standing in a 3D space, represented by points (x1, y1, z1) and (x2, y2, z2). Player 2 is holding a light source, pointing in the direction given by a normalised vector (xn, ...
0
votes
2answers
211 views

Moving an object at an angle based on quaternion rotation matrix (c++)

I have been trying to figure this out for a while now, and can't seem to get a working method. I am building a space ship movement with the following movement keys: P = accelerate (move forward) A = ...
1
vote
1answer
52 views

Calculate heading required to turn ship so that its weapon can fire at target

I have a ship, the ship travels towards a heading (vector3, blue arrow) with an arbitrary speed. The ship has a weapon on the side, the weapon can point in any direction, except straight forward/...
0
votes
1answer
48 views

Why rotating an object only on its local X axis result in sudden 180 degrees changes in Y and Z axis rotation values

I have an object (cube) in the scene and I want it to continuously rotate on its only local X axis but suddenly while rotating on X axis its Y and Z axis rotation value goes 180 degrees for some ...
0
votes
3answers
417 views

Creating orientation Quaternion from forward vector

Suppose that I have an orientation Quaternion Q, I can compute its forward vector from V = Q * Vector3.forward easily. ...
0
votes
2answers
51 views

Bullet spread changes depending on the camera direction

I'm working on an FPS game. I want to make a little bit of difference in shooting direction, only on the horizontal axis. To do this, I wrote this code: ...
1
vote
1answer
80 views

How do I calculate a new position from current and target position for intuitive non-instant dragging?

I have a simple 2D game where I can move an object using the mouse. I've been improving on the 'feel' of the movement gradually, however it still doesn't behave as you'd expect if the object were to ...
0
votes
1answer
31 views

How to get 60fps animation in terms of rounding/truncating position/alpha floats

I am wondering what gives the best animation performance running at 60fps with lots of objects. I have seen in a few places such as this that you should round or truncate your values so you don't get <...
0
votes
1answer
64 views

Choosing the correct normal for a collision

I have taken the task of building a basic impulse physics engine. Circle vs Circle collision resolution has been done and I moved onto Line vs Circle. I can detect a collision and know that the normal ...
0
votes
1answer
60 views

How can I detect if I move circular with my Gameobject?

I want to detect if my Gameobject (Vector3 Point) is moving circular. For that i thought its a good idea to safe the last 5 Points every 10 frames and make line-Vectors out of it. Then I thought I ...
0
votes
1answer
213 views

OpenGL vector rotation matrix to a given point

I have a sphere with a radius of .5 The sphere is centred at 0,0,0 I am now trying to place items around my sphere based on a given x,y,z on the surface of the sphere. My items have been draw/...
1
vote
2answers
105 views

Find hexes on a hex grid given an angle

I'm trying to find an elegant solution to calculating the x, y values of hexes that are crossed or intersected by a line or ray at a given angle from a given hex position on a hex grid. I do not want ...
0
votes
1answer
255 views

Check whether a vector is to the left or right of another position

I don't know how to decide if my point is on the left or right side of another object. My first thought was to check if x-axis of object1 is bigger or smaller than object2's, but if my objects rotate ...
2
votes
2answers
89 views

Given a point on a 2D grid of discrete points, and a normalized direction vector, how to I find the next point in that direction?

Say you have a point on a grid, lets call it P and your have a direction vector called V, how do i find the closest point from P in V's direction ? Example: 1|2|3 4|P|5 6|7|8 V = (0.5 , 0.5) In ...
0
votes
0answers
1k views

Copy vector3 values to another vector3?

Sorry if my question looks silly. I want to copy vector3 values to another vector3. Also, use float on other case. ...
1
vote
1answer
50 views

How to Work With Arbitrarily Oriented Vectors

I'm brushing up for a pending game jam and just for kicks I thought I'd let the gravity in my 2D platformer push at an arbitrary angle. Normally gravity points downward (3 PI / 2), but if I wanted it ...
1
vote
0answers
29 views

Switch Vector 3 x,y,z Components Based on Rotation

I have a cube that moves by rotating on its edge. I want my code to also work for cuboids. The following code is what I'm using to rotate my cube: ...
1
vote
0answers
172 views

ANSI C (C11) math libraries? [closed]

I know there are a multitude of C++ math libraries out there, but my current project is C-only (C11). So far I've made due with writing my own matrix/vector functions, but now I need to do the more ...
3
votes
7answers
2k views

Benefit of using Vector2 data type over separate x & y variables

I'm really curious about why a lot of people and game engines use Vector2 as its coordinate system instead of the traditional x and y value. Is there any benefit to this? I feel like it's just slow ...
0
votes
1answer
31 views

Extract formula from vector drawing

I am creating a game with HTML5 canvas for browser. I want to create animations with many shapes, which would be drawed with canvas, not from spritesheets. The problem i face now is - to create ...
1
vote
1answer
91 views

Find Coordinates of Exit Point

I'm trying to make a bullet penetration system. Taking a look at the picture below could help explain what I want better. If we know the coordinates of a square shape as well as AB vector with ...
4
votes
1answer
115 views

2.5D game vector choice

I'm developing 2.5D game (3D assets, 2D gameplay). Since gameplay takes place on horizontal plane, majority of game objects have y component equal to 0. Most of my algorithms work on ...
0
votes
1answer
130 views

Unable to control speed of the movement - object jumps straight to the end of the curve

I have implemented curve movement for two sprites (moon and sun) to simulate daytime changing. Sprites should take turns one after each other and move over the sky. But they just instantly appear at ...
0
votes
2answers
3k views

Moving a 2D object along circular arc between two points

I have a sprite which I need to move along a curve between two points in 2D space. Speed must be consistent all the way. No physics involved. How can I achieve this? The object is sun sprite.
1
vote
2answers
1k views

Unity Vector3 position inside collider

I am trying to create a "wander" action that will make my NPC walk to a random position. The catch is that the NPC should only go positions inside of a collider. I have a huge Sphere that has a ...
1
vote
1answer
32 views

How can I calculate the new vector of an object trying to push into (move along) the ground?

Say I have a sphere (planet). If I have object on the surface, I want to limit movement so that it can only travel in directions along or above the surface. Imagine a coin on a table. If I were to ...
0
votes
0answers
124 views

Draw Lines on Camera's Viewport

I wanted to know if there is a way to draw lines on the viewport, just like on the example image I am posting. My idea is to have a method that receives 2 Vector2, the origin and the end of the line, ...
1
vote
2answers
182 views

In Unity, is there a difference between Vector3.down and -Vector3.up?

I've noticed numerous tutorials and examples using something like "transform.up * -1" or "-Vector3.up" instead of simply saying "transform.down" and "Vector3.down". Is there a good reason for this, ...
0
votes
1answer
80 views

Generate 4 vectors rotated in cardinal directions from a central vector

There is some unit vector, which is a coordinate in a spherical space. It is necessary to obtain from it 4 vectors diverted in different directions (right, left, forward, backward) by a certain number ...
0
votes
1answer
91 views

Trying to use 3D vectors for a 2D ping pong game

I am trying to setup a virtual ping pong table, and am getting a little stuck in trying to understand how to do 3D vector math and render it in 2D. So far, my plan is for the ball: X = up/down, Y = ...
0
votes
1answer
419 views

Changing texture offset in unity by script

I am trying to change texture offset in a material by a script to create a parallax effect, but it doesn't move a bit no matter what I am trying. Any tips for this case? Or am I missing something?
0
votes
1answer
70 views

How to Calculate Caridnal Direction from Unit Vector

I have unit Vector of acceleration in local space of object. Now I want to calculate Cardinal Direction from (North, East, South, West). So Far I tried to: ...
0
votes
1answer
29 views

Divert gameobject around mesh surface

I am trying to find a way to divert a vector3 position around the surface of a mesh which doesn't have a collider. I have a function (found online) that calculates the closest position on the surface ...
0
votes
1answer
37 views

Calculate the amout that should be added or subtracted to x and y axis with rotation?

Say I have this figure: How would I calculate the amount I must add or subtract to x and y axis to get the cube to move in the direction its facing? The rotation is a float 0 - 360 and 0 is straight ...