Tag Info

New answers tagged

0

Why does it have to be 1 specifically? It doesn't. It's just a standard. If you want so in your game, you can make all your vectors of length 2. I wouldn't call it normalized though because normalization has a mathematical definition of its own. As long as you have all your vectors in the game standard (all of them of unit length N, doesn't matter what N ...


2

Christian's answer already covers most of what you asked for expect your concrete example from the end of your question about representing "North-East": First of all, it depends on your coordinate system. But if we look onto your world from the top and assume that North/South is the y-axis (+y = North) and West/East is the x-axis (+x = East), you could ...


6

A 2D vector has two values (x and y), and it basically says how far you go from the point of origin in the x- and in the y-direction. For example, a vector of (3,4) goes 3 units in x direction and 4 units in the y direction, resulting in an angled line with a length of 5 (3² + 4² = 9+16 = 25, root of that is 5). So the vector basically gives you two pieces ...


3

Fly along circular arcs You start at x1, moving in the direction v1 and want to end up at x2 facing in v2, then the shortest path (assuming a finite turning radius, which realistically should be proportional to the square of the velocity) takes you along an arc of radius r1around m1, followed by a straight line segment and then another arc of radius ...


1

I would add some AI (artificial intelligence) checks. A first thing to do would be to check if the distance to travel, in comparison with the distance to the enemy makes sense to apply the Bezier curves. For example, you could make the weight (i.e.: distance from the end point to the control point of the Bezier curve) depend on the distance travelled and the ...


3

Following the half-plane method, you'll have found the line segments to every other point and the perpendicular bisectors of each of those which you then intersected to find potential vertices of the Voronoi cell. Now, you want to exclude the ones that intersect any of the "distant" half-planes formed by the bisectors. I coloured the "distant" ...


3

You may simply iterate over edges and filter out all vertices that are not in same half-plane with point of interest. As optimisation, iterate from nearest edges to farthest. I think you may even filter vertices while generating slices. It is like slicing pie with endless knife, until only small piece left with cherry on it. If you like analogies. Just cut ...


2

A possible solution is to use the Dot Product. Of course, you need two vectors and not two angles, but I guess you're using them (otherwise I wouldn't explain how you're having 3D angles). Quoting Van Verth & Bishop from the book Essential Mathematics for Games & Interactive Applications, page 30-31: A more common use of the dot product is to ...


0

This seems to get the job done, special thanks to a forum member Entity for this answer: core::vector3df(sin(core::degToRad(rot.Y)), -sin(core::degToRad(rot.X)), cos(core::degToRad(rot.Y))).normalize();


1

You can do the trig functions yourself if you want, but it's a lot easier to use a rotation matrix. In the background it will do the exact same sin/cos stuff, but it's already programmed for you, so why redo it? I'm not too familiar with Irrlicht (or C++), but adapting some code I found on their forums, it'll probably look something like this: ...


0

There is also a Vector3D class in Apache Commons Math.


-1

Move along X axis only, test for colision, if true invert X movement. Repeat for Y.


0

It is actually very simple, I have this exact thing in my game. I will solve it in a pseudo code manner. Obtain the coordinates of the gun that is firing. var gunPosition; Obtain the coordinates of the target. var targetPosition; Subtract the targetPosition FROM the gunPosition and store it in a new variable. var difference; Now you can either compute the ...


0

Try: position + directon. The method here is called raycasting. IT can be used in various ways. (cannonPosition & cannonDirection are vector2's) Like. vector2 bulletPosition = cannonPosition + cannonDirection * i Just. do: float bulletSpeed = 0.5f; float shootRange = Gun.getShootDistance(); /*(EG: 100)*/ float gravityConstant = 0.1f; float gravity ...


-3

Calculate the angle between the origin of the shot and the mouse position with the arctan2 function.


-1

Without screenshots or an idea about where the origin and target are, and what kind of coordinates you're registering for your mouse, it's really just blind guessing on my side. I think your problem is here: float dirLength= (float) Math.sqrt(dirX*dirX + dirY*dirY); dirX=dirX/dirLength; dirY=dirY/dirLength; You're using distance between ...


1

Essentially your main problem is that you're not rotating correctly. Which is leading to other issues. When rotating I find it's easier to use the version of Rotate that takes an axis to rotate around, and the number of degrees to rotate. So: float degreesPerSecond = 45; if (touch.position.x < Screen.width/2) { transform.Translate (Vector3.left * ...


1

Not sure whats going on here. The whole point of vector is to convert the mouse location into a 3d point in front of the camera. Setting Z to camera.position.z when the frame of reference is currently focused on the camera (camera is 0,0,0) and then unprojecting that value into world space in particular makes no sense. var vectorx = (event.clientX / ...



Top 50 recent answers are included