8
votes
Accepted
How to raycast down to the floor plane to determine world space coordinates in Godot
I'm not sure I understand your limitations, so I will give you a few approaches, and hopefully this gets you to the solution along the way.
This is not an exhaustive list.
Pickable Object
If you have ...
6
votes
How can I randomly generate objects inside of a Complex Area?
Triangulate the area.
Pick a random triangle.
Generate a random point inside that triangle (link).
6
votes
Accepted
Finding all hexagonal grid coordinates inside cover arc
I prefer to do hex-cell coordinate math in what Amit calls cubical coordinates on your linked page. For the rest of this answer, (X, Y, Z) will refer to cubical coordinates.
Basically, for any of ...
6
votes
Accepted
How to convert a 4x4 matrix transformation to another coordinate system?
This is as easy as writing your old coordinates in terms of the new ones.
We want +x to map to +x (1, 0, 0)
We want +y to map to +z (0, 0, 1)
We want +z to map to -y (0, -1, 0)
We want the fourth, ...
5
votes
Convert quaternion to a different coordinate system
Summarizing your two coordinate spaces:
...
5
votes
Accepted
Handedness of 2D coordinate systems
It entirely depends on what you want to do with it and both have reasons why they exist.
The one where the top left corner is the origin and the positive xes point away from them are based on the way ...
5
votes
remaking Pong in Godot but the opponent AI cannot locate the ball's coordinate correctly
In the Godot editor, I made the silly mistake of placing the Sprite and CollsionShape nodes far away from the (0,0) origin point....
4
votes
How do I get the 3d coordinates of my model Instance? [LibGDX]
Try something like:
Vector3 position;
position = modelInstance.transform.getTranslation(new Vector3());
This gets the position and stores it in the ...
4
votes
How can I randomly generate objects inside of a Complex Area?
This might not be the most elegant solution, but it might work for you:
Define that shape as a PolygonCollider
Get the bounding box of that collider (...
4
votes
Accepted
Why does the Debug.DrawRay return these weird lines
You're drawing Rays, not Lines. This means that the second parameter is a direction not a point in space.
https://docs.unity3d.com/ScriptReference/Debug.DrawRay.html
Draws a line from ...
3
votes
Accepted
3
votes
Accepted
How do I convert positions between local coordinate systems?
What you have is the basics of 3D math, without any rotation. In 3D, we generally refer to an object's position as its translation, and set of things that describe its position (its translation, and ...
3
votes
how to create an outlined polygon with vector3 coordinates?
1)Find barycentric coordinates
for(int i = 0; i < verticesInPolygon; i++)
{
bary.xyz += vertices[i].xyz;
}
bary.xyz /= verticesInPolygon;
2)Create new ...
3
votes
Accepted
Convert global 3d coordinate system to a local one with specific direction
Construct a matrix like so, where each vector is one column of the matrix:
[ House's X+ direction | House's Y+ direction | House's Z+ direction | House's position]
The fourth row should be [0, 0, 0, ...
3
votes
Accepted
Alternatives to Camera.main.ScreenToWorldPoint in Unity
Basically, when you call Camera.main, Unity internally uses the FindGameObjectsWithTag to search through all of the objects in ...
3
votes
Accepted
How to invert a Tilemap's coordinate system?
It might be smarter to work with unity instead of against it and just accept how its coordinate system works. Keep in mind that this coordinate system follows the same "y is up" logic as the Unity ...
3
votes
Algorithm to check whether pizza toppings are divided half-and-half
After getting help from @DMGregory I was able to solve this by :
Getting the center of the toppingsA and toppingsB
Finding 6 most far toppings from the centers
generate 2 polygons based on these 6 ...
3
votes
Accepted
Ensure that random enemies don't spawn just near the player
The simplest system I can think of consists in testing the position of the new enemy before your screen.blit(), like so:
...
3
votes
Accepted
LookRotation function for Z-up, right handed system
First, we can transform your coordinates into Unity's coordinates:
...
3
votes
Should the coordinates, and rotation angles of all the sprites be stored in variables?
Storing values in variables is not the same thing as using magic numbers. The magic number anti-pattern is a direct usage of a number in the code.
For instance, compare the following code snippet:
<...
3
votes
Accepted
Algorithm for taking the shortest path between two XY coordinates
Your code makes him move vertical and horizontal if needed.
He moves the same speed both vertical and horizontal, that's why you only get a 45 degree angle.
He moves like this until there is no need ...
3
votes
Accepted
Is vertex coordinate limited to -1 to +1f range
I thought that everything outside of [-1.0f, +1.0f] should not be renderable in Open GL.
The [-1.0f, +1.0f] range is what you have to arrive at as the output of ...
3
votes
Accepted
3D-lighting considerations
I'm not a game dev, but I did take a class on this in college, and can give a brief tldr.
1990-1995 - CPU Rendering
The oldest "3d" games straight up did not take lighting into account, as ...
2
votes
clamp a 2D coordinate to fit within an ellipse
Here is a method for calculating the intersection between an ellipse and a line drawn from a point in 2D space (assuming the ellipse is centred around the origin):
...
2
votes
Difference in Shading Using Eye Space or Model Space Coordinates
First, you are misunderstanding the point of the article; these are not two different kinds of fragment shading. This is just an illustration two different coordinate systems.
Which one you use will ...
2
votes
Accepted
Unity 2d coordinates
you can make prefabs child of another object.so when you move parent , childs move along parent.then place it center of your scene.
...
2
votes
Why does handedness matter at all?
Handedness — and choice of axes, in the same way — matter because the camera has to match to get the results you want.
Suppose that you had a dataset (scene) which included not only the objects to ...
2
votes
2
votes
Accepted
clip space, normalized device coordinate space and window space in OpenGL
Clip space is the objects' position in a coordinate system relative to the camera. -Z is always in the same direction the camera is pointing. You get it by doing the necessary transformations on the ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
coordinates × 352mathematics × 52
unity × 50
opengl × 38
3d × 36
2d × 30
c# × 27
libgdx × 27
matrix × 27
camera × 23
isometric × 23
xna × 21
java × 19
rotation × 18
c++ × 17
transformation × 17
vector × 16
geometry × 15
textures × 14
javascript × 12
projection × 12
screen × 10
movement × 9
mouse × 9
linear-algebra × 9