- Home /
How to correct the First Person Controller orientation when parenting to a rotated x.270 degrees model?
Hi all, I am creating a simple lift and I have a problem. The lift is an imported model with animation, I attach the first person controller to the animated platform and it turns 90 on the side. Here is my code and some photos of the scene. Is there any solution to that? Can i rotate the controller after I attach it? something like FPCobject.transform.Rotate(Vector3(270, 0, 0),Space.Self);
if((hit.gameObject.tag == "liftani") && (showMenu== false)) { MouseLook.mouseLock=false; FPCobject = GameObject.FindGameObjectWithTag("Player"); FPCobject.transform.parent = hit.transform; FPCobject.transform.Rotate(Vector3(270, 0, 0),Space.Self); moveFloor(liftMoveSound, 3, "platform2_3UP", currentPlatform); //print(MouseLook.mouseLock); //FPCobject.transform.parent = null;
//showMenu = true;
}
Answer by duck · Mar 30, 2010 at 08:00 PM
How about just fixing the pivot orientation of your lift object (i.e. change it so that Y = up), in the 3D app that you used to make it?
@Duck Yeah, I was going to suggest that, but I didn't know which app he was using...
Thanks guys, model is co$$anonymous$$g from 3ds max, which I think it is NOT a very good idea after all! The model belongs to an hierarchy that has other animations too. if I change the pivot and put the y up (maya style) the platform comes on the side and I have to do the animation again because max stored the animation in world coordinates. I am importing from .max file directly which I thought it was such a cool feature !!! I am going to do a few more tests with rotating the pivot and let you know. Is that problem only for .max and z-up 3d apps?
O$$anonymous$$ I rotated the pivot like maya, and i have a very weird result. Everything works fine apart from the fact that the platform appears on the side in the beginning. when I activate the animation to go to another floor the platform turns straight and everything works fine ! It is a bit beyond me ...
Ok the only workaround I found is as you said to change the pivot, you turn in 3ds max the pivot to x:90 Y:0 z:180, the model comes on the side but the animation moves it in the right place ( Very weird). So I added an autoplay animation to play once in the beginning and then it works. I mean that is an ugly hack ! I can't figure how it works and what Unity does in the import. What if in the asset importer for max files whenever you read z you output y and x = -x (or something like that?). Is it more complicated ?
I reimported the model and the FPC rotates exactly as it was in the beggining the only difference is that the pivot is with Y up in the model. it's a mesh alexnode 0 secs ago
Answer by e-bonneville · Mar 30, 2010 at 07:54 PM
The answer might be as simple as creating an empty gameObject and putting your lift inside it. Then, add colliders so that the new gameobject gets the hits, not the lift itself. Then, add your code to the gameobject, and you should be set to go, since gameobjects by default are not rotated at all, thus no rotation of the camera when parent/childing.
Thanks elbon96, I have six different animations in this model and I would prefer to find a solution of not braking up the original file. if I put the animation on the root GO then the static geometry will move too. If I don't find any other solution I will have to do it as you describe, thanks. I think that I modelled the animations in the wrong way to be honest ... with this 270 degrees import issue from max.
Yeah, that can get funky sometimes... To be honest, I like importing my models from Blender and baking them. See this answer on how to...http://answers.unity3d.com/questions/4993/imported-model-gives-error-transform-rotation-is-no-longer-valid. Look at the answer on the bottom.
It is true that max doesn't have built in baking but there is a very nice script that does the job. But when you have different shaders and objects that react differently to scripts you don't want to bake anything.you want to keep them separate under the same hierarchy.The main problem is that the import from .max files does a funny thing of rotating the object x:270 degrees while the model appears straight. which is cool for static geometry but a problem when you want to attach something in runtime. And I am sure that I will find other problems too in the future. Thanks for the info
Hmm. By baking I meant bake the rotations and transforms so that they are imported as 0,0,0 rotation. If you can export as collada from max (I've never used it, I don't know), download and install blender and then bake rotations from there. I don't know if I misunderstood you, but it seemed that max bakes differently from blender.
by baking I understood that you bake some sort of modifier based animation like a ripple or bend effect (that cannot be imported to game engines) to vertex animation or different layered character animations to one . sorry. hmm i am not sure but i think the animation itself is imported correctly from max . I have to import a character to see more complicated staff concerning the rotation. The thing is that there is a maya machine in the studio and the import works ok. But I am interested in some rapid prototyping from max because we use max. The thing is that i am losing the "rapid"