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.
733
questions
0
votes
1
answer
25
views
Getting the scalar speed from an X and Y velocity [duplicate]
Given a Vector2(x,y) that represents an object's velocity, like so:
...
0
votes
2
answers
187
views
How do I use these Unity math functions in Godot C#?
Here's a list of math functions I'm having trouble finding a direct function match for in Godot C#:
...
1
vote
1
answer
94
views
Twin-stick backwards tank movement
I'm creating a 3D twin-stick tank game in Godot with C#. I have created the tank movement and rotation, separate of its turret, and it seems to be working properly.
The issue: I want the body of the ...
0
votes
0
answers
34
views
How can i translate this code into java?
My only problem translating the code from this question/answer is the Vector2 method. In the web i could only find this replacement (Vector2f). But i can not import it : can't resolve reference. Also ...
0
votes
1
answer
39
views
Modifying LibGDX vector2's seems to do nothing
I have a piece of code similar to this:
Vector2 test = new Vector2().setLength(20).setAngleDeg(45);
But when I'm trying to print its contents (such as ...
0
votes
2
answers
86
views
Is there a logical reason for SFML's Vector2 being templated?
The game development library SFML has a Vector2 class template (and a Vector3 for that matter), which can use any arithmetic ...
1
vote
1
answer
330
views
How to compare a vector to a rotation in Godot 4.1?
The Context
In Godot 4.1, I have a third-person character controller. It's a CharacterBody3D with a child Node3D called PlayerContent. The visual components of the character (model, etc.) are all ...
2
votes
2
answers
101
views
Finding the closest point on a circle to end of a ray in 3D
I have a circle in 3D space, so we have center C with radius r, and the normal of plane the circle lies on, N. There is also a normalized vector V that I am modifying to go far past the circle's ...
1
vote
1
answer
299
views
Godot Velocity: Invalid type in utility function "lerp", cannot convert arg 2 from Vector2 to float on line 40
I'm trying to solve a lerp problem on my velocity, searched some stuff here and there, but found nothing that solved it. Can you help me?
...
0
votes
1
answer
77
views
When to use InverseTransformDirection in Unity
I want to know when to use InverseTransformDirection.
Unity documentation says : "Transforms a direction from world space to local space". Honestly, it is not clear for me.
I came across ...
1
vote
1
answer
167
views
Raycast from isometric view without camera position?
I'm trying to cast a ray so I can implement mouse picking. My game uses 2:1 isometric with a 3D world sim that uses AABBs. Positive X points to the bottom right, positive Y points to the bottom left, ...
0
votes
1
answer
25
views
Changing one axis to another
Apologies for the bad title -- I have no idea how to explain this problem succinctly.
I have two 3D vectors. One is the player's movement direction, and the other is the direction towards a wall they ...
0
votes
0
answers
46
views
Calculate direction to push player away from wall
I'm trying to write a common 2D game and using vectors for physics.
I have 1 wall and 1 player object that can move diagonally (both are squares without rotation).
When the player object collides with ...
0
votes
1
answer
163
views
Calculate offset when attaching a game object to edge of another game object
I am doing a sort of hook, where whenever the hook collides with something, it retracts itself and pulls the the object it collided with back along with it.
But the objects the hook can collide with ...
0
votes
1
answer
32
views
How do I spawn the tiles on the global z axis instead of local z?
I'm trying to spawn infinite tiles in a 3D runner game, but the tiles are spawning at the wrong position and on the wrong axis.
Technically, the code is working as it should, it is spawning and ...
1
vote
1
answer
103
views
How do you rotate an object that uses a quaternion to represent orientation in 3D from a 3 vector input with values from a gamepad?
I'm using unity3d to create a six-degree of freedom flying game. The game takes in input from a standard dual-stick gamepad (like the Logitech f310).
In unity each of the gamepad's joystick's axes are ...
0
votes
1
answer
67
views
Why is the position of my GameObject inaccurate when copying another object's position?
I've been stuck with this nightmare for a while, and it's certainly my perfectionism. What I have is a cannon that fires a shell from an object pool. The order of operations is as follows.
The ...
0
votes
0
answers
43
views
Normalise movement for direction with 16:9 aspect
should i move everything by the windows Normalised cords to make it so SE is bottom-right, or should i use (1,1) and move everything at or either (1+speedX,1+speedY)
...
0
votes
1
answer
79
views
Help with understanding Vector3 math
I was making a 3rd person player controller in Unity.
Would
Vector3 inputDirection = orientation.forward * verticalInput + orientation.right * horizontalInput;
be ...
0
votes
0
answers
35
views
Predict whether projectile is coming at a teammate
Related to this question How to project a Vector3 onto the xz plane?
...
1
vote
1
answer
599
views
How to project a Vector3 onto the xz plane?
I have this code that tries to check whether a lobbed grenade will head toward a teammate:
...
0
votes
1
answer
296
views
Two methods of finding angle between vectors give different answers!
Ok, am I misunderstanding how Unity quaternions work, or is there a bad (about 2 degrees difference!) floating point error?
The TLDR is I use a quaternion r to rotate vector v and put the result in w. ...
0
votes
0
answers
297
views
How to set a position relative to my player's direction?
Currently I am setting my Player's position with:
transform.position = new Vector3(target.x, target.y, target.z);
However, the X and Z of this do not work the same ...
0
votes
0
answers
46
views
Reflections with Z and Y Swapped
When I look at my reflective sphere from one direction, I am able to get a correct reflection. However, when I go around to the other side, the reflection is not correct, but it is upside down instead....
0
votes
1
answer
165
views
Walk on any surface, how to make a defined space around character not pass through any collider
I'm working on an 3D insect/spider controller that will walk on any time of surface. Currently my character scan the environment around him by shooting a very big number of spherecasts and based on ...
0
votes
2
answers
673
views
Aim projectile to intercept moving target from a moving ship
So I have created spaceship shooter game where ships have turrets on them . Now I want those turrets to shoot a moving target meaning I want the projectile to intercept and hit the target that is ...
1
vote
1
answer
632
views
Find look at rotation with offset
I've been trying to make a function similar to "Find look at rotation" but with an offset. Imagine I have a pivot and an object attached to that pivot with some location and rotation offset. ...
0
votes
1
answer
519
views
Calculate the Right and Up vectors using yaw and pitch in right-handed coordinates
I have an assignment where they ask me to calculate Vector Right and Vector Up, it's for a camera creation using C++ and DirectX. For the Vector Right, they specify I should use 90-yaw, so I got:
\$ ...
0
votes
1
answer
847
views
Using atan2 vs dot product to get an angle in 2D games
I have some confusion that I need to be cleared up about the atan2 function.
I am making a game in Godot where a 2D ship rotates to face some object in space by ...
0
votes
1
answer
819
views
Implementation of Vector3.RotateTowards from Unity
I'm using vector3 as direction of object movement and i want to smoothly rotate it to another direction vector. I found SLERP but it rotate by percent. Looks like Vector3.RotateTowards is what i need, ...
0
votes
1
answer
53
views
How to find combination of vectors to equal target velocity?
I have a space craft in a 3d world that moves along the X Z plane. Given that I have 4 thrusters with one at each cardinal direction, and the ship can rotate itself about the y axis. Is it possible to ...
1
vote
1
answer
107
views
Given a quad in 3D space with two diagonally opposite points and normal, how would I find the other two points?
Image attached below for clarification:
So here we have a plane with a random rotation in 3D space, and we have the values for P1, P2, and the plane normal. How do I find the points X1 and X2?
This ...
-1
votes
1
answer
95
views
Move object on World's XYZ axes
I'm trying to move my Character on the world's XYZ Axes, but how do I get them?
I'm trying to do this because my Player is sort of a Sphere and is rolling around, so its xyz directions are rotating.
I ...
0
votes
0
answers
70
views
Include camera movement and calculation in the 3D game
I was sent here by softwareengineering.stackexchange.com.
I am writing a WinForms .NET application using C#. I use SkiaSharp for drawing for performance reasons.
I can already create a cuboid, rotate ...
0
votes
1
answer
87
views
Get component of velocity parallel to a normal
I would like to transform a rigidbody's world velocity into a local velocity based on a normal direction.
When the rigidbody is moving towards and within a range of a object, I use a raycast to ...
0
votes
1
answer
64
views
2D Vector local to global space without trig/sqrt
Per this answer to this question, a cheap way (i.e., without trig/sqrt) to convert from global to local space, given LocalOrigin, LocalI, LocalJ, and GloablPoint is (in rough pseudo code)
...
0
votes
1
answer
62
views
Finding point along vector to maintain distance to an arbitrary point
I'm currently working on a particular project where orthographic and perspective projections are both used interchangeably. To keep the transition between both projection modes somewhat seamless, I ...
0
votes
1
answer
100
views
Compute the difference between two vector3 and iterate with the difference in mathematically
I have two eularAngle vector3 A , and vector3 B;
I want to rotate the vector3 A rotate to vector3 B by 10 small steps;
...
0
votes
1
answer
509
views
Is it possible to calculate a direction vector without sqrt?
I'm not using Unity or any other library for making game logic. I'm making a basic game logic that needs to do basic vector math on the backend side.
I just wrote a direction function that needs to do ...
0
votes
1
answer
103
views
Move player towards screen
I've got a fixed projection perspective camera with a vertical FOV of 70 deg and rotated 45deg on Y axis.
Player movement is along Camera's X axis (right/left), Z axis (front/back), Y axis is set to 0....
1
vote
1
answer
907
views
Calculate normal and plane orientation using 4 3D points
I have 4 points as Vector3 in 3D space that shape a plane. How can I calculate the plane normal direction these four points create together, and express it as a <...
0
votes
0
answers
109
views
How does this 4 by 4 matrix (about 4 points are coplanar) come up with this equation?
I have just begun learning some 3d mathematics and OpenGL (trying to implement skeleton animation).
I am stuck here when reading a book(Advanced Methods in Computer Graphics). I understand the first ...
1
vote
1
answer
68
views
Rotating a command relative to the body of a drone
Suppose you have a drone the shape of a cube with rotors on each face, it's completely unable to control its roll-pitch-yaw, but it can accelerate along any of its 3D orthogonal vectors (see image ...
3
votes
2
answers
359
views
How to find vector representing altitude of a triangle?
I'm trying to find this green vector and I've got three points A, B, C. How can I find that vector in Unity code-wise?
1
vote
3
answers
67
views
How to calculate coefficient for how much a object with velocity x is moving towards point a?
I have a object in 3d space that has certain position and velocity. If that object moves perfectly towards point A, the coefficient should be 1. If it moves perfectly away from A it should be -1 or 0. ...
0
votes
1
answer
484
views
Calculate the coordinates of an offset in 3D space knowing the initial rotation and final rotation of the object
Working on a game mod in FiveM in which I am representing bullet impacts with drawn lines in the game world along their flight path. I am getting a normalized vector and then calculating the offset ...
1
vote
2
answers
178
views
Finding the position of a point based on a relative point inside a quad
I'm trying to get the relative point position on a quad using a [0,1] Vector2, like in the picture below:
The red dots are relative positions.
What I'm trying to make is a function that takes the A,B,...
-1
votes
1
answer
43
views
The vector aiming to enemy is in wrong direction
In a 2d game, I am trying to shoot at a moving enemy and the vehicle that is shooting is also moving. However, the velocity of the bullet is not in the same direction as the position of the enemy. The ...
0
votes
2
answers
543
views
Calculate the angle of rotation between two vectors relative to the first vector
I'm trying to get the angle between two 2D vectors relative to the first vector input. Every method I've tried has given me a value between 0-180 degrees but doesn't tell me whether it was a clockwise ...
0
votes
2
answers
425
views
Is it possible to project a vector on another vector to calculate the distance without raycasting
I have the following game scenario:
Player is P and there are 2 enemies E1 and E2
I want to calculate the distance between the ennemies and the player base which is anywhere in that green line, and ...