Tag Info

Hot answers tagged

3

First of all: most computer trigonometric functions takes radians as input. Even if the code worked, I am 99% sure it will not rotate by 90 degrees. So if it is that case, try changing it to pi/2. Secondly, if you would rotate by not-multiply of 90 degrees - the code would still produce axis-aligned rectangle (bounding box), NOT rotated rectangle as you ...


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 fixed the issue by changing the global coordinate system to the box2d one. Now the local 0,0 coordinates of my entities correspond to their center coordinates and they represent meters instead of pixels. EDIT (some clarifications): I now translate them in the render system (because this is really the only place where I need pixel coordinates): // get ...


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 ...


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 ...


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

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



Only top voted, non community-wiki answers of a minimum length are eligible