Tag Info

New answers tagged

0

To get the rotated sprites coordinate simply call the getVertices() method. For example: sprite.getVertices()[SpriteBatch.X2] Gets you the X coordinates of the top left corner. The same call but replacing X<number> with Y<number> gets you the Y coordinate. The corner numbers go like this: 2-3 | | 1-4


1

(coincidentally I just wrote about this topic for my book. That chapter should be released next week; here's a brief summary) There are two primary steps to what you're trying to do: 1) Determine which direction to face 2) Rotate the player to face that direction The first task is handled via transforming the direction vector from camera-space to ...


0

The problem was that libgdx has the origin (0,0) in the bottom left corner, but the mouse movement from the InputProcessor has (0,0) in the top left. What I had to do was adjust the mouse y position so that its (0,0) was the bottom left. I did this with: mouseX = screenX; mouseY = Game.HEIGHT - screenY; This will give the player coordinates and mouse ...


0

First, inverse the player position and the mouse position. This way, you will have the real angle from the player to the mouse, and not the opposite. Second, atan2 takes the y difference as the first argument, and the x difference as the second. That is probably why your code looks like it fails. Your code should look like this with the 2 corrections I ...


0

Try multiplying the y value with -1. And make sure to convert the mouse and playercoordinates to the world coordinates. I had this exact problem yesterday. It has to do with wrong conversion - think about the two different coordinate-systems (Viewport- and World-coordinates)


0

Try using different math techniques for the rotation: Instead of degrees, try using Quaternions. It's the most used rotation technique for 3D objects in professional engines, because degrees don't work as well in 3D. There's more on Wikipedia and I found some Libgdx code. I have more materials, but I can't include them due to my low reputation, but you can ...


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

Instead of mPointer.stopRotation() you need to gradually apply negative acceleration (torque) to get to your desired point. So, you have currentPoint, targetPoint and currentSpeed (I will measure all of them in grades as I guess that's also how you do it - for currentSpeed grades/second). The distance in grades that the wheel must travel from currentPoint ...


2

This is a classical control problem. You want to create a feedback loop that takes the divergence from optimal position and applies the appropriate torque to nudge it back into position. btQuaternion targetOrientation = // whatever you need btQuaternion currentOrientation = myObject->getOrientation(); Getting the delta orientation is quite simple, ...


1

I approached with a little Googlesearch ;) From what I found bt:RigidBody::applyTorque(btVector3 & torque) takes a vector in WorldSpace and uses it as axis to apply a torque which has a strength of the length of the vector. The LocalSpace-Torque seems to be solved in this answer, even though the provided code looks like there has to be an easier ...


1

This is somewhat long and might not work well if they are rotating faster than the deadzone value, but then you can just increase the deadzone. I've commented the below code: //declare new array of the dataclass we made below static AngleData[] angleDatas = new AngleData[] { new AngleData(90f), new AngleData(180f) }; int angleIndex = 0; //the deadzone ...


1

Short answer: by smart compositing rotation and translation. In the image below you can see the process (radius r is distance of your planet from star). If you rotate the moon by rot_m degrees(updated in main loop), it will circle the origin point. If you first rotate and then translate by radius r it will circle in right distance but wont follow your ...



Top 50 recent answers are included