# Tag Info

27

Have you considered that it looks very odd for a person to standing perpendicular to a slope? You need to be upright to stay in balance. Some alternatives: Treat his feet as a separate object and rotate them to be parallel to the slope. (A raycast will find the angle's normal, as dnk described. The angle for the feet is that + 90°.) Fake it, by ...

4

Use Transform.TransformDirection() method where Transform is your player transform. // Calculate the x-axis relative to the camera camera = Camera.main.transform; cameraRelativeRight = camera.TransformDirection (Vector3.right); // Apply a force relative to the camera's x-axis rigidbody.AddForce (cameraRelativeRight * 10);

4

At 90 degrees, you can work out rotations in both directions just by swapping and reversing positions. Begin with the following shape: Ahead, we rotate it manually clockwise, and look at the resulting positions (grey dots are rotated positions): Analyzing point B's position: Before transforming, it was (1, 2). After transforming, it was (-2,1). If you ...

4

A simple way to achieve this effect would be to launch the missile with an initial velocity of (ship's backwards vector + ship's rightwards vector), then apply a constant acceleration of (ship's forward vector) each frame, until it reaches some maximum forward velocity. Of course, that describes a "dumb" rocket that always follows that (rightward) ...

3

I found the solution myself. Here's what I've done: I took the default forward rotation of the firingPoint object, and split it into it's parts - x, y, z, w. Then from these floats, I create a new Quaternion using the constructor method: float randomX = Random.Range(-0.1f, 0.1f); float randomY = Random.Range(-0.1f, 0.1f); float randomZ = Random.Range(-0....

3

Your problem is not that tricky : you do have a formula that will give you the next position (at t+dt), given the current one. Now say the projectile is at P : use the formula to get the next point NP : D = (NP-P) is the direction vector at t. Now depending on what you seek : • Angle ? Get the angle (atan2) of this D vector, to have the angle of your ...

3

Calculate the dot product to determine how close two vectors are. The dot product is 1 when they are exactly the same, -1 when they are exactly opposite, 0 when they are perpendicular, and decimal values when partway. So take the current direction, the target direction, then Vector3.Dot() and check if greater than .9 (or whatever threshold you decide looks ...

3

Okay so imagine the image below is the front view of one of your faces on your cube: Ugly, I know. Currently when you do FACE.setRotationAxis(Rotate.X_AXIS) you are setting the rotation axis of that individual square to be the center of the square. The black dots in the image below are your rotation axes: So when you say to rotate, each cube rotates ...

3

In the case of a puzzle like this you can animate the rotation then reset the model back to its original position but with the cube's stickers rotated. Look at it like cheating with a real puzzle by moving the stickers. You'll have to make it possible to change the stickers' colors. This can be done with material colors or a dynamic texture. And this way ...

3

I don't know libgdx, but I know something that might help you, in fact some trigonometry will help you at this point. Normally I use parametric equation of circle for this purpose if I am unable to do it by all the other ways. Here is the parametric equation of circle x = r * Cos(theta) + displacementX y = r * Sin(theta) + displacementY where, r = ...

2

First, it won't solve your problem, but there are a few general problems with your code. The conditions for your if branch will always be true if transform.localEulerAngles.x >= 0 and <= 360. The > 270 part is redundant since if x is less than 270, it is still possible to be >= 0. If x is 0 and lookAxisX is > 0, then adding -lookAxisX will make x < 0,...

2

Something like this: transform.position = player.transform.position - player.transform.forward * distance; transform.LookAt(player.transform); where float distance is the distance of camera form player Consider also the solution 2 : Make camera child of player and in your player die script , you can "deatach" camera from player object transform.parent ...

2

Try using RaycastHit.normal on ground to get normal. Them put char.up = normal

2

You can use Quaternions instead of Euler Angles to solve this. transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(rotationDestination), Time.deltaTime * rotationSpeed); If you want to test distance still, you can use... if(Quaternion.Angle(transform.rotation, Quaternion.Euler(rotationDestination)) > 0.2f) I'd suggest you ...

2

jhocking's answer about dot product is the right answer to the question, but if you are rotating your object over time to face the right direction, inside that function you must be calculating how much you have left to rotate so that you know what direction to rotate and so that you don't rotate too far and overshoot. That means that inside that function, ...

2

You seem to be stacking matrix calculations. The "node original transform sources" should be kept pristine while calculating "node in the graph stuff". Assuming your original code looks a bit like this: bool haveParent; Node* parent; Mat4 rotation; // or Quat Mat4& getRotation() const { return rotation; } Vec3 position; Vec3& getPosition() ...

2

Keep your world coordinates, movement, and rotation on a standard X/Y coordinate grid (like your leftmost image) and then convert those coordinates to isometric coordinates via linear transformation before rendering. This question has some good answers on how you might make that conversion. As far as how you would rotate your sprites, assuming they're 2D ...

2

Short answer: To store position, use a single vec3. To store rotation, use a quaternion and normalize it after every multiplication or after every n (1-1000) multiplications. You shall only use mat4s when it comes to drawing or transforming lots of vertices: Convert vec3+quaternion pair to mat4 and pass it to your shader or use it to transform vertices ...

2

Lets approach this from outside the code. You are attempting to have user input make on object revolve around another. This means that we have two objects, the fixed object A, and the revolving object B. For A we draw it at one location and it never changes. For object B we start it at an initial position and update it's position every tick based on user ...

2

"Is it wrong that I am counting total rotation and then creating [a] quaternion from it?" Yes, because rotations do not combine like simple addition. (In mathematical terms, rotations in three dimensions are not commutative) Here's an example you can do with any old mug. Turn it 90 degrees on the vertical axis, then flip it over away from you (finish ...

2

Something like this is often easier if you avoid using angles. The following assumes you know the world coordinates of the center of the planet and the world coordinates of the location on the planet surface that you want to place the object . Matrix GetWorldMatrixForModel(Vector3 surfaceLocation, Vector3 planetCenter) { Vector3 modelUp = Vector3....

2

Well, the pivotX/Y/Z are the effective origin point of the rotation. Pretend these are (0,0,0) at first and that the center of the cube is at the origin. The Point3D object is a unit vector describing the arbitrary line around which the cube will be rotated. E.g. (1,0,0) would cause it to rotate around the x-axis. If the vector was (1,1,1) it would be a (...

2

I think this article is what you are looking for. Article from opengl tutorials Basically, you'll have to find the matrix camera rotation and apply a derived form to your mesh. Hope it helps!

2

I'm incline to suggest there is no 'right way' to do this but I think there are 'better ways' and some considerations to make when implementing your own system. Should an object's transform be authoritatively a world-space matrix, or a local-space matrix? If you are going to have deep, complex hierarchies, storing a local-to-parent transform (or separate ...

2

In this case, the matrix is generated from the call to Matrix.CreateRotationZ, which is a function (a static method of the Matrix class). It creates a 4x4 tranformation matrix which describe a rotation about the Z axis. The formula for constructing that matrix can be seen here, as Rz. Extending that the 4x4 form used for the Matrix class, it would look like ...

2

You need to: "Move" the origin - translate the ship by -CenterPos (the position of central character) Do the desired rotating Move back translating by CenterPos tip: automate the process by creating a function like RotateAround(Point) see any "transformation composition" tutorial for detailed explanation.

2

You will need a forward vector which represent the forward direction of your ship, and the velocity of your ship. // Stuff that you need (or already have) vec3 shipForwardVector; // This is according to your game infrastructure // and ship model; make it a unit vector. mat4 worldSpaceRotationMat; // assuming ship!.transform is only ...

2

Just setting your bodys angular velocity means that it rotates around its center. You never definded the point it should rotate around. Sadly in Box2d you can't define a rotation origin, but you could try this: Define a static body for your fixed point Define your rotating body Use a Joint to link these 2 bodies Apply a force to your rotating body Update ...

2

As mentioned, pygame doesn't directly offer support for rotating hitboxes. However, you could either look into coding your own non-axis aligned box classes, or use a little cheat. The cheat basically calculates the axis-aligned hitbox that completely contains your sprite. It's pretty easy to calculate, and might be good enough for your game, depending on ...

2

NOTE: Edited because it was likely too verbose (source). A rotation matrix actually always defines an orthonormal basis. What this means is each column defines one of your original axes in its rotated state. For example, consider a simple rotation matrix around the z-axis (more on rotation matrices here). Let's say we plug in Pi / 2, in other words, we ...

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