Stack Exchange Network

Stack Exchange network consists of 174 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
25 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
9 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
44 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
51 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
97 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
42 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
27 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
111 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
37 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
65 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
26 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
41 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
54 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
131 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
81 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
119 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
72 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
587 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. ...
0
votes
0answers
32 views

Change node color in spritekit

I have a vector illustration of a branch with a few leaves on it. I am moving the branch from the bottom of the screen to the top of the screen. But as the branch moves from the initial position (...
1
vote
1answer
47 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
26 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
161 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
89 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
109 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
88 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
2k 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
551 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 ...
0
votes
0answers
64 views

Why does my gravitational orbit gain energy so fast?

I'm using something like Verlet integration, it seems to work alright except orbits degrade very quickly. ...
1
vote
1answer
27 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
70 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, ...
0
votes
0answers
48 views

Rotating a camera around an object with PhysX

I'm working on a PhysX project with GLUT and I'm attempting to have a camera rotate around an object, steered by the mouse. My first step was to port over the C# code found here: http://wiki.unity3d....
1
vote
2answers
141 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
55 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
80 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
300 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
54 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
25 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
36 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 ...
0
votes
1answer
156 views

Unity wheel collider extra camber angle

I want to give the value of a camber to the wheel collider my game. When the car stops, there is no problem visually, but as the wheel rotates, the wheel makes odd rotational movements together with ...
0
votes
0answers
39 views

How do I calculate a point between two points with a given distance percentage? [duplicate]

I've made a simple drawing: The distance between these two points is calculated with a simple formula: Which gives: 5,38 I need to calculate the green point's coordinates, which is set at 80% ...
0
votes
1answer
195 views

Trying to get an object to move in the mouse direction XNA C#

Right, so in my Player class where I call the object I got an if statement which gets the coordinates for the mouse ...
0
votes
0answers
39 views

Combining Quadtree with goal based vector field, in java?

preface if you're not interested in the setup then skip to the question itself in bold please I'm working on a "tile based" (its complicated) top down dungeon crawler I've implemented a labyrinth ...
1
vote
2answers
520 views

Unity: Creating a Plane from 3 Vectors

https://docs.unity3d.com/ScriptReference/Plane-ctor.html public Plane(Vector3 a, Vector3 b, Vector3 c); Description: Creates a plane. The resulting plane goes through the given three points. ...
-1
votes
1answer
51 views

How do I move a target camera along Y axis

I have a camera that rotates around a target point on mouse move. How can I move the camera's position upwards/downwards related to the target position? So when camera is moved upwards the object is ...
0
votes
0answers
27 views

Find centre of rotation from two locations

Ultimately I need to get c from the image and have a, b and that it takes 90 degrees to get <...
0
votes
0answers
79 views

How can I spawn an object where I clicked in a 3D space, but spawn it in a 2D location?

I have a game where I have an object sat on a 3D plane and I want to click above it to drop an object. Wherever I click I want the object to drop where I clicked on the Z-axis, but on a fixed ...
0
votes
1answer
57 views

Compare two x and y if they are in a valid range

Today my mind is a little foggy, the right thing was for me to do it the other day, but I will not, I will continue today. XD I need some help to think and find a way that works without bugs. What I'...