I want to export my blender model to unity, but every time I do that, my object in unity has a wrong forward direction
I tried rotating the armature to -90 degrees in X axis, then applying the rotation, and then rotating it back to 90 degrees without applying the rotation, but that doesn't help in my case.
One thing that I noticed when trying to fix the problem, is that when other people rotate their objects to -90 degrees, they get their object facing top
But when I do the same thing, my object rotates like this
I've tried importing to unity both as blender file and FBX, and also tried setting forward direction to different axis when exporting as FBX file, but the result is always the same in Unity. I know there is a method in unity of creating an empty gameobject and putting the model in it with right direction, but I really want to fix my model in blender rather than doing that.
Blender has a different axes order.
When exporting, you have the option to export with Y axis up.
Hope it helps.
This is an expansion on Zivdo's answer:
In Blender, +Y is forward and +Z is up (yes, this means we all do our modeling with the model facing backwards), but in Unity, +Z is forward and +Y is up. Thus when creating an exporter, it's simply a matter of swapping the Y and Z values in the vectors (a little more for quaternions and matrices). This is why the fbx exporter has the forward and up options: it takes care of the swaps for you, all you need to do is tell the fbx exporter the correct settings (and maybe ensure your model has the correct orientation (with rotation applied) in blender).
Related
The problem I have is simple. When I export my file in a blender as fbx and import it to the unity, the objects (or part of the objects for some reason) turn into the wrong axis while it looks ok in both blender and fixes file. I looked at google for this problem. Most of them did not help me. I saw that coding might help. I found a code that can help me which is this:
transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, 0);
But the problem remains because it changes all of the rotation of the road, so the right roads become wrong while wrong roads become right. Putting this in the necessary planes might work but there are so many planes and I will put more planes in the blender project in the future so it won't help me too much.
I have two options.
Write a code that changes it to the right axis if the plane/object looks at the wrong axis.
Find the right way to import it.
I don't how to do any of the time since I am a beginner. I use Unity 2019.4.33f1 and Blender 2.83. Please help me
https://drive.google.com/drive/folders/13Y-lnccTvNPWPKAT520CCM8u-7MgaXkR?usp=sharing
Thank you
EDIT: I put my blender file to the drive link as well.
EDIT2: I keep editing I know but I realize that I have another problem as well. The problem is that Unity gets my object wrong, for example, I have a half green half red object and I want both colors to be at the +y axis. It makes the red part at -y axis. Here are the pictures: https://drive.google.com/drive/folders/1ob5xdKv0nPHN3TSABHGDVA7inW8vkag6?usp=sharing
How can I fix this :'(
LAST EDIT: I found a way to solve it. I added the same object twice but one of them has a different setting. Assume that rotations are 0 0 0 (x y z respectively) and scales are 1 1 1 (x y z respectively). The second road will be different settings from the first road. Its rotation settings will be 0 0 180 and the scale will be -1 1 1. Of course, I am open to better suggestions but this is the solution I found.
SOLUTION: After a long time later, I finally found the answer. I updated this in case someone needs it later. All I had to do was calculate the normals again and the way we do is, after choosing all of the roads, Edit Mode -> Mesh -> Normals -> Recalculate Inside / Recalculate Outside
Blender uses a left handed coordinate system, where the Z axis points upwards, whereas Unity uses a right handed coordinate system, where the Y axis points upwards. There might be some extensions or packages to keep them the same, however you probably just have to rotate the model in Unity or Blender to fit your needs.
I'm working on a project that needs to read the joint data from motion capture device to reconstruct the motion.
I already have a model in MAYA where all the joint are having Y axis up-pointed. However, when I import that model to unity, many koints' rotation changed. I've tried different importing method including exporting a FBX then load to Unity and ecpoting to unity directly. I've also changed the default rotation in MAYA from XYZ to ZXY. But the problem still exists.
The mesh will twist since due to the wrong rotation as shown in the picture below. I've googled a lot but still not find a solution.
error listed
Usually the joint direction doesn't matter, though I used to set "z" instead "y" in my character rig.
Please go to your fbx import settings, choose your Rig/Animation Type as Humanoid. Then, create a new avatar Definition from this model.
You should now be able to remap your wrong or missing joints. It's most likely that you have wrong order of character joints' mapping.
I've been looking for a solution to this for quite a while now (meaning several days) and I haven't found anything yet. Maybe I'm thinking about it wrong and there isn't a way, but let's try!
I'm recording hand-data on a Hololens (the Unity Hololens Input Simulation for now). This essentially gives me one float AnimationCurve for each hand joint for each transform.position.x to z and rotation.x to w. Now my goal is to put these curves into an AnimationClip and add it to an AnimatorController (via an AnimatorOverrideController) that animates a hand rig and replay the recordings. Everything so far works!
However, the recorded hand-data from the Hololens is in world scale, not in local scale. (which makes sense, since you usually want absolute coordinates when you want to know where the hand is.) But to animate the hand, it seems I'm only able to set local coordinates, which I don't have.
Example:
clip.SetCurve("", typeof(Transform), "localPosition.x", curve.PositionX);
Here, the clip takes the the x-coordinates from some hand joint and puts it to the localPosition.x of the corresponding hand rig joint. The problem: curve.PositionX is world-scale (absolute coordinates), but localPosition.x takes local-scale (coordinates relative to its parent).
I can't simply change "localPosition.x" to "position.x", like so:
clip.SetCurve("", typeof(Transform), "position.x", curve.PositionX);
even though the Transform class has both properties and position is the object's world scale position. I'm not sure why this doesn't work, but it gives me the following error:
Cannot bind generic curve on Transform component, only position, rotation and scale curve are supported.
I'm aware that it doesn't make much sense to use absolute coordinates for an animation, but I simply don't have anything else.
Does anyone have an approach how I can deal with this in a sensible, not-too-cumbersome way? It seems I have all the important parts, I just can't figure out how to put them together. Thanks so much already! :)
From my basic understanding, it seems like you are using the Input animation recording service provided by MRTK. Unfortunately, MRTK does not provide the localPosition version of Curves data. However, you can modify the data from the recordingBuffer after the InputRecordingService stops recording.
So, this is a method worth trying for you: in the handJointCurves dictionary property of recordingBuffer field, a set of pose curves is stored for each joint. And then, base on this table:Joint pose curves, subtract the position value of the key None from the position value of each other joint in every key frame so that the localPosition based on the key None is obtained.
Alrighty,
I have a dumpster model I have exported from Blender as an FBX. The transform, rotation and scales have all been applied in Blender. when importing into Unity and then adding to the scene, the model is elevated and rotated at an odd angle to the transform as per the image.
The model has an armature for animating the lids an I have applied the location, rotation and scale on it as well.
Any one else come across this or know of a fix?Thanks
Blender image
Incorrect dumpster transform and location image
The problem is that Blender uses the right-handed coordinate system which means the Z-axis is pointing upwards.
Unity uses the left-handed coordinate system which means the Y-axis is pointing upwards.
To fix this, set the X-axis rotation of the model to be -90. Press Ctrl+A and apply rotation. The X-axis rotation will look like it is now 0 after that. Set it to 90 again and export it to Unity.
This 3 minutes video should also help you do this if you are still confused.
If you still have problems, check your animation. Don't apply it to your model and see if it's the problem.
Also as a side note, you can use blender files (.blend) directly with unity. So every time you modify them inside your project folder they change in unity as well.
The simplest way to solve this would be as follows:
Create a dummy game object (D)
Transform/offset the position of D to make sure your object's position align with the dummy parent
Put your game object as the child of the dummy game object D
You can then apply transform on D, rather than your own game object directly.
I have a 3d model in Xcode using SceneKit, that can rotate around itself, and i would like for it to move forwards based on rotation, for example if it is rotated 236 degrees in the z axis, it wouldn't go straight in x or y, but a bit of both so it would move forwards. Is it possible? Do i have to get any plugins?
No plugins required.
You can do this two main ways:
Move the object's position relative to its rotation by changing its "transform" over time.
Applying force (and/or impulses) over time (or instantly) in the direction you'd like your entity to travel.
Within these two approaches are a LOT of other considerations regarding scene size, resistance, speed, immediacy, etc.