Search Unity

UFPS : Ultimate FPS [ RELEASED ]

Discussion in 'Assets and Asset Store' started by VisionPunk, Mar 9, 2012.

Thread Status:
Not open for further replies.
  1. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    This is a perfect job for the State system.

    1. Start the game and tweak a camera position that's off to the left side.
    2. In the Preset foldout, click "Save Tweaks" to save this position tweak to a new preset text file.
    3. See the "State Manager" chapter in the manual for instructions on how to bind the preset to a "LeanLeft" state and in turn bind the state to a key via script.
    4. Repeat for "LeanRight".
     
  2. Unicron

    Unicron

    Joined:
    Sep 28, 2011
    Posts:
    191
    Very cool! I'll be trying this. The State System sounds very awesome indeed, can't wait to try it out, thanks!

    Also in the demo webplayer I noticed that you have to hold in "C" to crouch, how would I change it to toggle the crouch on/off instead of holding the key in?
     
    Last edited: Aug 16, 2012
  3. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Pretty amazing how good and snappy that pistol reload "animation" is. Reading the comments in the code it's almost as if you visualized the animation happening as you were adding the forces. :)

    @Unicron, just change the initial lines in the InputCrouch() method from:
    Code (csharp):
    1. if (Input.GetKeyDown(KeyCode.C))
    2.     SetState("Crouch", true);
    3.  
    4. if (Input.GetKeyUp(KeyCode.C))
    5.     SetState("Crouch", false);
    to:
    Code (csharp):
    1. if (Input.GetKeyDown(KeyCode.C))
    2. {
    3.     if (Controller.StateManager.IsEnabled("Crouch"))
    4.         SetState("Crouch", false);
    5.     else
    6.         SetState("Crouch", true);
    7. }
     
  4. Unicron

    Unicron

    Joined:
    Sep 28, 2011
    Posts:
    191
    @TwiiK, thanks I'll make sure to try that out.
     
  5. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Checked out Interstellar Marines again (http://www.interstellarmarines.com/) and noticed that they've opted for a single camera setup, but has made no attempt to fix the weapon clipping through geometry issue. Kind of disappointed with their progress though. Over 2 years since they wowed me with their initial demo and since then barely anything has happened. Don't understand how someone can work so slow.

    I'm currently going with a single camera as well because proper image effect support as well as shadows was the most important features for me. Currently trying to fix clipping, but my initial attempts produced some amusing results. :p

    A single camera could allow me to have some really immersive features like seeing your character actually grab ammunition from his pockets when he's reloading, seamlessly throw weapons or used clips on the ground, show the actual wounds my character has suffered on the first person view model if you look down etc.
     
  6. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,536
    I'm heading in this direction with the kit as well, keep us posted on your progress please.
     
  7. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    I do not mean to hijack this thread, but I remember someone asking how to achieve that effect of seeing your own legs when you look down and having it line up with shadows, etc.

    This is what I came up with after playing around for 10 minutes, it's not perfect by any means and the perspective is slightly off, it feels a bit like you have your head on your waist, but, check it out (look up/down with mouse):

    http://dl.dropbox.com/u/19877504/FpsLegViewDemo/WebPlayer/WebPlayer.html

    Also I would strongly advice against going with just one camera, as it will cause you immense troubles ;P
     
    Last edited: Aug 17, 2012
  8. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    @fholm, for seeing the players legs I actually just took the character from the Bootcamp demo, cut off his arms and head in 3d studio, and placed him as a child of my camera then played the correct animations when he moves forward, strafes etc. and this actually looks really good if I may say so myself. Further down the line I will of course create and animate my own character, but this setup works a lot better than I imagined it would.

    As for the camera I've explored a lot of setups and a single camera is what gives me the least troubles in this project.
     
  9. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,536
    Using a single camera is a project specific choice. It will definitely cause less problems for me and the gameplay element I'm going for.
     
  10. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    Yep thats pretty much how it should be done:D
     
  11. Unicron

    Unicron

    Joined:
    Sep 28, 2011
    Posts:
    191
    Would definitely love to know how you accomplished this :)
     
  12. Likos1

    Likos1

    Joined:
    Aug 12, 2012
    Posts:
    14
    I'm guessing this doesn't work if the player does not use the cylinder default character. Does it? By that I mean do the animations work with most human models?
     
    Last edited: Aug 18, 2012
  13. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    This package includes no animations and it doesn't depend on your character at all. It adds spring physics to your camera and weapon so you can use any models you want to.
     
  14. Likos1

    Likos1

    Joined:
    Aug 12, 2012
    Posts:
    14
    So does this allow me to have my player hold the weapon? Do I need to create extra animations for the player model?
     
    Last edited: Aug 18, 2012
  15. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Of course you can have the player hold the weapon. I don't even know why you would doubt that was possible.

    And yes, you will have to create animations for that unless the spring physics isn't enough.
     
  16. Likos1

    Likos1

    Joined:
    Aug 12, 2012
    Posts:
    14
    Ok thanks
     
  17. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Hi guys, Just back after a 3 day mini-vacation. My back hurts less now :)

    I think TwiiK's method is the way I would've done player body too. Child an animated character to the FPSPlayer (with his head and arms cut off). It will exist in the scene and cast shadows, play animations etc. like everything else. If you go with a single camera the weapon and arms will cast a shadow too.

    Actually this "headless dude" method would work regardless of whether you went with one or two cameras. Neither method is "wrong", they just have different pros and cons. Basically: with single camera you will have trouble preventing the gun from sticking through walls and the player body, and with dual camera you may have some issues with shadows and image effects (depending on what fx you want to use). In the latest release of UFPS it should be fairly easy to skip the weapon camera. Let me know if there are any troubles.
     
  18. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    There is an issue in v1.3 that breaks Character Controller trigger detection. It's due to the crouching code updating the scale of the Unity CharacterController every frame (which probably breaks its internal trigger detection). Here is a temp fix:

    Go to vp_FPSController.cs -> Update()
    At the end of the method, replace the "handle crouching" code with this:

    Code (csharp):
    1. // --- handle crouching ---
    2. if (m_Compact)
    3. {
    4.     if (CharacterController.height != m_NormalHeight * 0.5f)
    5.     {
    6.         CharacterController.height = m_NormalHeight * 0.5f;
    7.         CharacterController.center = m_NormalCenter * 0.5f;
    8.     }
    9. }
    10. else
    11. {
    12.     if (CharacterController.height != m_NormalHeight)
    13.     {
    14.         CharacterController.height = m_NormalHeight;
    15.         CharacterController.center = m_NormalCenter;
    16.     }
    17. }
    Ofcourse this will be amended in the next version.

    /Cal
     
  19. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    375
    I'm in the middle of making a rigidbody manipulator gun and whilst I think I have the manipulation code down I'm not yet sure how to fit it into this awesome FPS controller system. The gun is similar to the one in GarrysMod, 30 seconds into this video: http://www.youtube.com/watch?v=ffwB_SU0n0s
    Just wondering how I should set this up in respect to this?
     
  20. Gogs

    Gogs

    Joined:
    Aug 15, 2012
    Posts:
    8
    Realy Good VisionPunk, Just Bought pack :)

    Any way to walk without weapon ? and then on click to draw weapon ?
     
    Last edited: Aug 23, 2012
  21. SevenBits

    SevenBits

    Joined:
    Dec 26, 2011
    Posts:
    1,953
    Probably not built in, but you can code it yourself.
     
  22. Unicron

    Unicron

    Joined:
    Sep 28, 2011
    Posts:
    191
    You can always create a model of the arms without a weapon and add that to the weapon list and name it "no weapon" or such.
     
  23. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    VisionPunk, I think this would complement your asset well: http://wiki.unity3d.com/index.php?title=EditorUndoManager#C.23_-_HOEditorUndoManager.cs

    Seeing as everything is a custom inspector in Ultimate FPS Camera. Installed it here and it's working wonders. Only problem is that it doesn't open the foldouts when you're undoing, but that's a minor problem opposed to not having undo capabilities at all. :)

    Also :p:


    Basically I added a Zoom group to both the weapon and shooter script for storing the iron sights / zoomed in values I was interested in.

    And I changed the recoil controllers to what I felt was more intuitive. The main difference here is that it allows random recoil both horizontally and vertically.
     
  24. Gogs

    Gogs

    Joined:
    Aug 15, 2012
    Posts:
    8
    Nice thinking Unicorn, i wonder how i didnt come up with that idea -.-
     
  25. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Hello strich, Well, if you have the manipulation code, you can go about it in a few different ways:

    • Create a monobehaviour script and add it to the weapon gameobject. The rigidbody manipulator script will be disabled / enabled along with the weapon. Add an FPSShooter script that doesn't shoot anything if you want recoil, sound and ammo
    • Copy or modify the vp_FPSShooter script so that it supports your rigidbody manipulator code upon fire. The shooter script currently spawns a gameobject. Your version could instead fire / activate the rigidbody manipulator.

    Hope this helps

    /Cal
     
  26. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Hi Gogs. Thanks for buying! Yeah, like Unicron said you can create a weapon with empty hands. You can also always use the SetWeapon method to set weapon 0, in which case there will be no hands and no weapon.

    Here's what I would have done: in the vp_FPSPlayer script create an int variable, for example 'm_LastWeapon' to remember the number of the last weapon wielded, then create a new 'ToggleHolster' method that does SetWeapon(0) if that integer is not zero, and SetWeapon(m_LastWeapon) if it is. Then just bind this method to the 'H' button. Oh, and update the m_LastWeapon every time player switches weapon ofcourse.

    Cheers

    /Cal
     
    Last edited: Aug 24, 2012
  27. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    @TwiiK: Sweet! The Undo functionality seems very useful. Thanks for the tip. Cool to see a modded setup too :)
     
  28. Gogs

    Gogs

    Joined:
    Aug 15, 2012
    Posts:
    8
    Vission Punk Maybe u can make More Weapon models, all kind of weapons like m4 AK-47 m16 etc....fully functional, i would buy that anytime!
    I am not Programer so its kinda hard for me to implent weapons and make them fully functional in game.
    -------------

    Anyway, how to set Ammo limit? so far i can shoot and reload as much as i want. How to make that ammo can be depleted, so i have to pick up ammo to have.
    So far i have infinite ammo ammount and can never spend.
     
    Last edited: Aug 24, 2012
  29. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    I agree, if you would implement different functional weapons it would be really cool. Not just guns, even swords or bows would be nice.
     
  30. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    @Gogs janpec

    Great suggestions. I will consider both. This is definitely possible.
     
  31. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    There is a new version of Ultimate FPS Camera. It's a small hotfix update addressing an issue with triggers.
    Check out the release notes HERE.
     
  32. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Off the top of my head; I'm thinking the amount of ammo clips should not be stored on the shooter because the mags can theoretically be used on different guns.. So you could add a variable to the vp_FPSPlayer script to keep track of how many clips the player has. Then, in "vp_FPSPlayer.Reload" (executed when the player presses 'R') you deduct 1 from the variable and only allow it to execute "CurrentShooter.Reload" if the variable is above zero.

    Cheers

    /Cal
     
  33. SevenBits

    SevenBits

    Joined:
    Dec 26, 2011
    Posts:
    1,953
    Okay, so, can you give us a YouTube tutorial on how to add new guns to the system. I am re-writing my current project and would vastly prefer not to have to code my own system, so perhaps a tutorial on how to add guns models not included with the system into the game would help to coerce me to choose your package.
     
  34. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    +1 Guns and arms. ;)
     
  35. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Hi SevenBits, Adding a new weapon is super easy. It is basically: add a child weapon gameobject (or any object) and drag a script to it. This is explained in great detail in the PDF manual, along with how to add projectiles, creating advanced player states and much more. The manual is 60 pages and shock full of info. You won't be disappointed.
     
  36. WarpZone

    WarpZone

    Joined:
    Oct 29, 2007
    Posts:
    326
    Hey VisionPunk. I have no new problems or suggestions at the moment, I just wanted to say that I recently downloaded the new version, and I really like the direction you're taking it. Text assets make a lot of sense, I like the new Vp_FPSPlayer concept, etc.

    Did you ever get the Image Effects fixed in Pro? I'm currently using 1.31.

    Keep up the good work, man. You work hard to support your users, and as a result, some day soon this sucker is gonna really be deserving of the name Ultimate! :)


    Edit 1: I figured it out... at least, partly. Did you know your FPSPlayer prefab has two Cameras in it? FPSCamera and WeaponCamera. Turns out, WeaponCamera is the one you need to attach the Image Effect scripts to. I think people were attaching them to FPSCamera.

    Upon closer inspection, it appears both cameras are neccessary. The first camera renders the scene, then the second Camera only draws the gun. This totally makes sense to prevent (for example) a long sniper rifle's barrel from poking through a nearby wall. It seems the second camera's image effects override the first, so the easy solution is to just add your image effects to the second camera.

    Let me know if I'm missing something.

    Edit 2: Oh, I figured out why it doesn't look the same in Preview as it does in-game-- BOTH of the cameras have their depth set to 0! This is a huge no-no when rendering multiple cameras, and I'm guessing it gets corrected at runtime automatically, which is why it worked at all.

    To fix, follow these steps, starting from 1.31 as a base:

    - Add any Image Effects to WeaponCamera. (Greyscale is a great test.)
    - Set WeaponCamera's camera's Depth to 1.
    - Set WeaponCamera's Clear Flags to Depth Only. (I guess some script currently does this at runtime?)

    Now when you click Game, you see your background, you see your gun, and you see the greyscale filter applied to the Camera Preview. Hooray!

    Culling Mask gets tweaked at runtime to something custom, and I see no real reason to change this behavior just yet, but it's worth taking note of for the future.

    Edit 3: Whoops, I guess I spoke too soon. Greyscale works as-expected with these changes, but Screen-Space Ambient Occlusion still doesn't.

    Edit 4: I just realized, I just dropped the FPSPlayer prefab into an otherwise empty scene. So my experiences may not be typical. Are there preparations needed to make my scene ready for FPSPlayer? Do I need to set up custom layers, for example?

    Edit 5: After some experimentation, it seems if all of the following are true:

    - Weapon Camera's Clear Flags is set to Depth Only
    - Weapon Camera's Culling Mask is set to Everything

    then SSAO works, but only up to the edge of Weapon Camera's Far clip plane. Naturally, this ruins the whole thing by re-drawing the walls and stuff from another angle. But they're properly AO'd.

    I don't understand why we can't just put an SSAO on FPSCamera, OR why if SSAO script is called after all layers are drawn, why doesn't it take the composite as the input?

    Maybe someone from UT could help... I'm out of ideas at this point. (Sorry.)

    Edit 6: Possibly Related:
    http://forum.unity3d.com/threads/145396-Camera-Culling-Mask-help!

    Edit 7: The problem *appears* to be in SSAOEffect.cs. Whatever it's doing, it's doing it with the exact input from the camera the script is attached to, not from the composite of all the cameras rendered so far. It might be possible to get data from multiple cameras and combine them manually within SSAOEffect.cs. However, I don't know how you would do that, since it involves something called a "Depth+Normals texture," which seems to be handled under the hood and is not very well documented. You can decide whether or not a particular camera will generate a "Depth+Normals texture," but I don't know anything about what that format looks like, how it is stored, how it is accessed directly, or even when it is created. (Could be generated when RenderTexture.GetTemporary is called, but that is a guess.) The Shaderlab forum might be a good place to ask about this, or IRC.

    Edit 8: Oh, man. I'm an idiot.

    SSAO script on FPSCamera works perfectly, no script on WeaponCamera. HOWEVER, this only works with Forward Lighting. Deferred Lighting kills any Image Effect script on FPSCamera. In Forward Lighting, applying a SSAO effect to WeaponCamera cancels this the one on FPSCamera, oddly enough. Fortunately, one camera can be set to Deferred or Player Settings, while the last camera drawn is forced to use Forward Lighting.

    Edit 9: Recap and Happy Ending! To fix the Image Effects issue in Unity Pro, starting from scratch:
    - Download 1.31 from the Asset Store and put the FPSPlayer prefab into a new scene.
    - Set FPSCamera's layer to 0 and WeaponCamera's layer to 1. This allows accurate previews in the Game View.
    - Change other camera settings to be like at runtime. (Clear Flags, Culling Masks, etc.)
    - Apply any Image Effects you like to any camera you like. (You can create some interesting effects such as a full-color character in a black-and-white world!)
    - From here, most effects such as Blur and Bloom will work as expected on WeaponCamera
    - However, if you want SSAO, the image effect script must be on FPSCamera, AND FPSCamera's Rendering Path must be Deferred Lighting, AND WeaponCamera's rendering path must be Forward Lighting.
    - If you wish to layer more cameras into this system (a dynamic skybox, a Mesh HUD, etc,) remember these basic rules:
    * Anything drawn after SSAO must be Forward Lit.
    * Any geometry with SSAO applied to it must be Deferred Lit.
    * All other Image Effects may be put on any camera, but
    * Image Effects don't influence layers above them, only layers below them.

    Let me know if it still doesn't work and if there's any other rogue Image Effects I didn't notice yet!
     
    Last edited: Aug 25, 2012
  37. SevenBits

    SevenBits

    Joined:
    Dec 26, 2011
    Posts:
    1,953
    Fantastic. Now, at the risk of sounding annoying, could I maybe see the manual?
     
  38. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    I have chosen to keep the manual exclusive to buyers. The asset is very affordable, though. I've put 1028 hours into it and it's currently only $20. If you have questions about it after purchase I'll be more than happy to help out (and if it still doesn't work you can always get a refund).

    /Cal
     
    Last edited: Aug 25, 2012
  39. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Thanks for the recap WarpZone! Glad you like the asset and the customer support :) FYI: there is quite an extensive chapter in the manual covering much of the same issues. Please let me know if you found any parts of the manual inaccurate.

    Thanks again

    /Cal
     
  40. WarpZone

    WarpZone

    Joined:
    Oct 29, 2007
    Posts:
    326
    Gah. >_< Yes, thank you.
     
  41. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    So what are everyone doing with the asset? It's been a while since anyone posted videos or screens. I'm very curious to see what's being built! =)
     
  42. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
  43. HolBol

    HolBol

    Joined:
    Feb 9, 2010
    Posts:
    2,887
    This asset is fantastic. You've got a customer (once I get paid).
     
  44. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
  45. SevenBits

    SevenBits

    Joined:
    Dec 26, 2011
    Posts:
    1,953
    Okay, I just may have to purchase then.

    @TwiiK, that game looks interesting. I'm going to try it as soon as I can.
     
    Last edited: Aug 26, 2012
  46. strich

    strich

    Joined:
    Aug 14, 2012
    Posts:
    375
    Hi Cal,

    Thanks for your previous reply. I'll look at implementing it this weekend and will definitely try to post a little video for you.

    Another question I have: I'm making a realistic game and would like to have the camera be able to view the full body of the player if they look down. I know there was a solution a few pages back around adding an armless/headless body and animating it but I wonder if its a bit too hacky. Would be nice if I could have the whole body complete so the arms line up with a body when animating. Having never done this before I may be unaware of some limitations in doing this. Your thoughts?
     
  47. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    @strich, I don't think I know of any games where they've used a complete body.

    Most games use 2 camera like there is in the Ultimate FPS Camera package. One camera renders arms and weapon while a second camera renders everything else including the torso and legs. You would never be able to see your own shoulders anyway so in the end it doesn't really matter, except that it's trivial to set this up compared to the work involved with a whole body I assume. Also the 2 camera approach give you the ability to have independent field of view on the gun and the environment as well as avoid clipping between gun and environment.

    I've recently accepted that everything you see in games is hacky because either it's not possible to do it properly or it's not feasible so I'm accepting hacks of my own. :p

    That being said I was actually thinking of using a whole body myself, but I have to get quite a bit better at animating first, and I think it will be a pain in the ass, if it's even possible to get it to look good at all. Looking at how they've done it in the third person example or the bootcamp demo is perhaps a place to start. You would have to do at least the same amount of rigging, animating and scripting as they've done in those examples I imagine to have the torso properly twist and arms properly follow the torso etc.
     
    Last edited: Aug 27, 2012
  48. ozoner

    ozoner

    Joined:
    Jun 8, 2009
    Posts:
    85
    What an excellent piece of work. Will mobile controls be aded at some time in the future ?
     
  49. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Hi ozoner,

    Yeah it's not supported out of the box yet but maybe in future releases. Though plenty of people have used it for mobile projects and it seems it's not that hard to get it working. See the following discussions:
    http://forum.unity3d.com/threads/126886-Ultimate-FPS-Camera-RELEASED?p=921763&viewfull=1#post921763
    http://forum.unity3d.com/threads/126886-Ultimate-FPS-Camera-RELEASED?p=934829&viewfull=1#post934829
    http://forum.unity3d.com/threads/126886-Ultimate-FPS-Camera-RELEASED?p=941358&viewfull=1#post941358
    http://forum.unity3d.com/threads/126886-Ultimate-FPS-Camera-RELEASED?p=946712&viewfull=1#post946712
    http://forum.unity3d.com/threads/126886-Ultimate-FPS-Camera-RELEASED?p=947516&viewfull=1#post947516
     
  50. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    @strich: Yeah I think TwiiK's response was quite thorough. Let me know if there is anything else.
    /Cal
     
Thread Status:
Not open for further replies.