Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

3ds Max export First Person Animations to Unity

Discussion in 'Animation' started by Nick Brooks, Oct 6, 2015.

  1. Nick Brooks

    Nick Brooks

    Joined:
    Mar 19, 2015
    Posts:
    12
    Hi, I am puzzled how developers import their view models. Considering they make up nearly 15% of the screen, I can not find any documentation regarding my issue.
    My problem is that when I export the FBX, Unity imports the camera incorrectly forcing me to flip it 180 degrees on the Y axis. So, if I wanted to spawn the hands in front of the camera for a different animation, the player would not be able to see the view model. I do not know if the problem is the camera not configured correctly in Max or its within the exporter, or maybe its something else. I would highly appreciate any documentation involving the workflow developers use.
     
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Search around if you want to find proper FPS workflow. There are a lot of references on the forum available.
    I can give you a small hint about the camera though, Use the camera in Unity not Max, just to save money on headache medicine down the road. And if you want to set up the camera exactly like you have it setup in Max, just create a dummy/point object in Max for a placeholder and export that with your character. When in Unity orient the Unity camera to the dummy/point object, set the fov the same and it will be setup the same as the Max camera.
     
  3. Nick Brooks

    Nick Brooks

    Joined:
    Mar 19, 2015
    Posts:
    12
    Sorry, but I am still confused,their are many workflows for this aspect of development. One is to spawn the object with the object held linked to the arms to be exported with the FBX in Max. This limits customization of objects and whenever you want a new object, you have to spawn another prefab animated in Max instead of using the same model. The other is to create root nodes and export only the arms in the FBX, while spawning objects via code within Unity. I do not know how to code this or create root nodes for objects in Max, in addition to that different objects need different nodes such as a clip and a gun.
    A tutorial or link to a forum that provides insight to the rigging process would be awesome. I am frustrated with this side of development because I have had to re-rig countless models.
     
  4. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Yes - there are many workflows for this and several tutorials on youtube that address this.
    You have to decide which workflow you want to use - which matches your preferred process and what you need to accomplish in your game.
    If you can't code, you need an alternate process that can be used in place of not knowing code. Some use other peoples code, and try to cobble together something that works. I prefer to create working products that I can understand so I use Playmaker.
    I have links to several FPS tutorials on youtube, but don't have the patience to look them up right now.
    If you haven't found a working solution in a couple more days of research - ping back here and I will provide you with some additional research material to check out.

    Another small hint. Root nodes (your words) are just attachment points that are setup in Max and exported into Unity for placement/attachment for additional mesh objects. For instance you can place a dummy object at the palm area in Max, and in Unity orient/parent the weapon to this palm dummy. This allows the gun to be switched out at run-time or in the editor without having to complicate matters by having all weapons parented to the hand bone at export and turning off the mesh renderer in Unity for which ever guns are not being used.
    But that is another optional process that works - and others have used successfully.
     
    eses likes this.
  5. Nick Brooks

    Nick Brooks

    Joined:
    Mar 19, 2015
    Posts:
    12
    After searching for the right workflow that suits my project I have narrowed the process down to one.
    1-Import animations into Unity with root nodes
    2-Configure using mechanim so I can extract future animations
    3-Spawn object via code onto the rig
    Though this process adds a lot of functionality, while testing this process I've encountered some problems. One being that if I wanted to animate a reload animation for the rig, I would have to parent the arms to that clip for a certain length of time, assuming that the rotations would be correctly in align. Keep in mind this is first person, so having the rig compact and neat within the viewport is a necessity. The other is that since my rig is not a humanoid, I do not know if I can extract the animations. I have found the UDK skeleton documentation helpful with this problem but it was dealing with third person not first person :(
    Any advice is always much appreciated.
     
  6. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    This is backwards.
    Consider the arm/hands as the main body (root) of everything. All weapons (and attachments) should be parented to the hands, attachments parented to gun, and gun parented to hand, not the hands being parented to the clip/magazine.
    So for a magazine/clip you want to have an attachment point parented to the gun model and the gun model parented to a root node dummy object which is parented to the hand. This root node dummy object isn't really needed, you can parent the mesh directly to the hand, but I prefer an additional level/layer that allows the mesh to be manipulated if needed.

    In Unity parent the root node dummy object to the hand however, then animation plays, reload is needed so the hand animates up to the magazine, at a specific time in the animation the magazine would change parent from the gun to the left hand and the hand would remove the magazine. Hands usually go off screen at this moment in a FPS view, and this is when (usually) a texture swap takes place on the magazine first texture is the magazine empty, the second texture is the magazine loaded with bullets.
    As the hand comes back up to the gun the magazine changes it's parent from the left hand back to the gun and then the next shooting animation plays.

    The gun and the magazine have no animations on them at all. They are inanimate objects, unless for the slide animation or some special fx. The hands control all the animations and by unparenting/parenting objects you get the correct results.
    That's pretty much it - others may have different solutions, but that's how I used to do it and it works. I haven't worked on FPS contend in over 3 years, but the process is logical and works like it's supposed to.

    I've not dealt with generic retargeting yet. I do know the names of the bones have to match. There is info here in the forum regarding this also. You can look at Mecanim.Dev and TonyLi posts for the most useful information about generic retargeting.
     
    eses likes this.
  7. Nick Brooks

    Nick Brooks

    Joined:
    Mar 19, 2015
    Posts:
    12
    Okay, thanks for the great input, this issue has been troubling me for a couple weeks now. I have just a couple more question now, If you have to eject the magazine would you have a node for that as well then parent the magazine to the node via code? If so how do you program that in, I have not found no features that allow for this functionality which directs me toward having separate clips for injecting and ejecting the mag.
     
  8. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Your asking the wrong person about code bits. :)
    I have written one line of code in my entire life - it was to start the render farm when I logged off my machine. haha
    You are talking about when the clip is ejected from the gun without the left hand removing it right?
    So yes for the non-coder process, I'd have a clip parented to a dummy, or empty game object, and that would be parented to the gun. This allows the magazine to animate when needed if you want it to flip or fly off in a certain direction, but physics might be a good solution also if it is on screen for longer than 5 frames.
    Anyway - to eject the clip, just unparent the empty game object from the gun and at that point the animation would play for it to fall away.
    To inject a clip if it's not done by a left hand, it has to be put in there somehow - so the new clip will have a parent object that is either animated into place or placed there by it's parent object. When in the proper location - parent it to the gun.
     
  9. Nick Brooks

    Nick Brooks

    Joined:
    Mar 19, 2015
    Posts:
    12
    Ok, thanks a bunch.