Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Realistic FPS Prefab [RELEASED]

Discussion in 'Assets and Asset Store' started by Deleted User, Apr 5, 2013.

  1. Deleted User

    Deleted User

    Guest

    The Realistic FPS Prefab is an easy way to implement the core features of first person games into your Unity projects with a few mouse clicks. Set up is quick and just requires dragging and dropping the FPS object into your scene and assigning a layer to collision geometry. The asset has been designed with a focus on keeping scripts simple and ensuring that motion and effects are smooth and glitch free. The Realistic FPS Prefab is a great learning tool and template for FPS games.

    What features does the Realistic FPS Prefab offer?
    Full physics interaction with a rigidbody character controller that has mass in the game world. Pick up and throw objects, ride elevators and horizontal platforms, create physics puzzles, and climb ladders.

    Player state handling for sprinting, crouching, and jumping movement states with seamless transitions, easily configurable speeds, and air manipulation. Player health management with damage from falling, enemy fire, and elevators is also included.

    Advanced weapon positioning using sine bobs, iron sights, weapon sway, position changes based on player movement state, and animation for actions like reloading and readying weapons.

    Camera movement effects such as weapon fire, landing, and pain kicks, as well as camera view animation to accompany weapon actions like reloading. Fully configurable sine bobbing based on player movement states is also supported.

    Weapon behavior customization allows switchable auto and semi auto modes, shotguns, scoped weapons, accuracy handling, single shell reloading, and melee weapons by modifying the variables of one script instance from the editor - no additional scripting required to make a new weapon.

    Item pickups to place in your scene for ammo, health, and weapons that can either be static or moveable (and throwable) rigidbodies.

    Weapon effects like bullet impacts, smoke, tracers, and ejecting casings with simple variables to control size, velocity, and ejection delay of shells.

    Ease of use through extensive documentation and commented code, simple drag and drop functionality of game objects into scenes, compatibility with version 3.5 and higher of Unity free and professional, and customization variables accessible from the inspector.

    An example sandbox scene with an improved default AI for testing.​
     
    Last edited by a moderator: Jan 30, 2019
  2. ProjectOne

    ProjectOne

    Joined:
    Aug 9, 2010
    Posts:
    442
    Hi, that looks good, nice asset.
    1- The one thing I felt missing was the typical 'Q and E on keyboard to peek/see around corner.
    2- Any part of your code u think it won't be compatible with iOS?
    3- Will u be adding touch-control for mobile devices from out of the box compatibility?
    4- guns currently used in your web demo, are they included in the asset and ok to use for our own games?

    Thanks
     
  3. Deleted User

    Deleted User

    Guest

    Thanks ProjectOne, Q and E leaning is a good idea and I’ll add it to the list of upcoming features.

    This asset was developed with a focus on the desktop platform and IOS compatibility hasn’t been tested as I don’t have access to the licenses, but we have tested for functionality and framerate independence on a variety of desktop systems with success. As far as I know, the only part of the code that would affect performance on slower hardware is the fixed time step value, which is set to 0.01 (100 FPS) for smoother physics instead of the Unity default 0.02 (50 FPS).

    On an Intel 1.8GHz dual core, there hasn’t been a noticeable decrease in performance, but a 0.02 fixedDeltaTime value could be used for mobile development. The rigidbody movements won’t be as smooth and the push forces would have to be lowered, but all runs well using both 0.01 and 0.02 fixedDeltaTime values.

    Ideally, the asset would use the default 0.02 fixedDeltaTime, but ragdolls and rigidbodies that have their parents modified during runtime seem to loose their interpolation. Still looking into whether it is my code or a quirk in how the physics are calculated In Unity. A decrease in the fixed time step might not even be noticeable on smaller screens.

    The only other issue I can think of would be if Unity has to use lower precision floating points on mobile. If the player travels 1000 or -1000 units from the origin, positional inaccuracies (spatial jitter) start to show up. I’m looking into a fix for this, which involves moving all objects back to the origin, but it isn’t high priority because 2000² units is a decent amount of room to work with.

    These pages describe the topic pretty well:

    http://pompidev.net/2012/12/21/3d-graphics-quality-and-floating-point-accuracy-on-android/

    http://answers.unity3d.com/questions/54739/any-solution-for-extreamly-large-gameworlds-single.html

    A simple work-around would just be to place the player at the origin or around a -500 x or y position and have them move into positive x and y values, but not exceeding the range that causes spatial jitter. Lower floating point precision might not even be an issue on mobile, but it’s something to be aware of.

    As far as out of the box touch controls, it’s a possibility, but it wouldn’t be for a while because I don’t have a way to test code on mobile yet. The way player input is handled in this asset is fairly simple and I imagine it would just involve setting up the touch button/virtual pad code and piping it into the Input.GetKey references in the scripts. We are also available for support if you have any questions about how the input code works.

    The gun models were put together using Creative Commons licensed models and animated by us, so they should be ok to use in your games.

    Hope that answers your questions.
     
  4. TheRealFuzz

    TheRealFuzz

    Joined:
    Jul 17, 2012
    Posts:
    308
    This looks really cool but I'd like to ask a few questions first before I buy it. Do you know if any of the scripts are compatible with Ultimate FPS Controller, such as your ladder scripts and you physics pick up? :)
     
  5. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    668
    Curious as well.
     
  6. ProjectOne

    ProjectOne

    Joined:
    Aug 9, 2010
    Posts:
    442
    Thank u for your clear reply Azuline. Good stuff
     
  7. Deleted User

    Deleted User

    Guest

    Thanks TheRealFuzz and lod3. The ladder script was designed to have the least amount of code as possible (for efficiency if there are a lot of ladders/climbing surfaces) and just sets a climbing boolean value in the character controller script to true or false. The character controller then uses the climbing value to determine when to add vertical climbing speed to the total player velocity.

    So to add our asset’s ladder climbing the Ultimate FPS Camera, you would need to locate where total player velocity is calculated in the character controller and adapt the appropriate code there from our project. I’m not sure if the Ultimate FPS Camera uses a rigidbody character controller, but if it does, the rigidbody.velocity could be set to something like Vector3(velocity.x, climbSpeedAmt, velocity.z);

    We could have made the ladder climbing script more self contained and portable without so much integration with the charater controller, but it wouldn’t be optimal if there are a lot of ladders in the scene whereas the character controller has just one instance in the scene and has access to other variables that affect player velocity.

    On the other hand, the rigidbody dragging/physics pick up script is more portable and can be added to another character controller object with an attached rigidbody.

    We’ve made a lot of effort organizing our code in a way that is easy to understand so that it can be modified and used as a learning tool for Unity. We are also available for support if you have questions.
     
  8. TheRealFuzz

    TheRealFuzz

    Joined:
    Jul 17, 2012
    Posts:
    308
    Thanks for the reply! I think I may have to take a chance and grab this asset :)

    Also, any idea how compatible this is with networking?
     
    Last edited: Apr 6, 2013
  9. jonkuze

    jonkuze

    Joined:
    Aug 19, 2012
    Posts:
    1,709
    Wow! this is pretty awesome! = ) I'll need to get this one really soon. Good job! and Thank you for such a Great Asset! Only I would suggest maybe changing your Assets Category, I would think this goes under Complete Project / Template Category, instead of just Scripting. You may want to update this to ensure you get sales from people who are not on the forums and looking through that category for more complete assets like this one.
     
  10. jonkuze

    jonkuze

    Joined:
    Aug 19, 2012
    Posts:
    1,709
    Questions... I see you include a bot with AI.

    Does the AI use Path-finding (+navmesh), with a Node Grid setup or something? is does it work without these...?

    and finally can you somehow tweak the include AI to work for Zombie's that do Close Range Damage, instead of Long Ranged (since zombies don't shoot lol!) please do let me know.
     
  11. TheRealFuzz

    TheRealFuzz

    Joined:
    Jul 17, 2012
    Posts:
    308
    So I bought it and everything is working pretty well but I have a problem. When I use the rigid body grab script, when I drop objects they fall to the ground really slowly instead of fast.
     
  12. Deleted User

    Deleted User

    Guest

    Thank you TheRealFuzz, networking hasn’t been tested with this asset, but I assume that it would be compatible. I haven’t delved into networking with Unity yet and the only problem I can think of might be with the rigidbodies. A lot of physics calculations would mean higher latency, so if there was a way to selectively make some of the physics (like bullet shells and ragdolls) client side, networking would be faster.

    For the rigidbody falling problem, are you using a new scene, or is this happening in the included sandbox scene? You might want to check that your gravity setting in Edit->Project Settings->Physics is set to something like 0, -9.8, 0. Also, on the rigidbody component of the object you are dropping, is the drag value set to something high like over 0.6 or so? Or is the rigidbody’s mass set to a very low value? You might also want to check if the fixed timestep value in Edit->Project Settings->Time is anything other than 0.01 or 0.02 when running the scene in the editor.

    Either one of those could cause slow rigidbody falling. If you are still experiencing the issue could you please post, email, or PM me with specific details about what happens when you try to drop the rigidbody, like if you are running the scene in the editor or standalone, if there any printed errors, or unexpected movements of objects? I appreciate the feedback TheRealFuzz!

    Kurato, this asset does seem to be more of a complete project/template , I’ll have to change the asset category for the next update :)

    The included AI doesn’t use pathfinding or Unity’s navmesh. The main focus of this project is FPS player mechanics, so the AI is there just for testing at the moment. The next step to improving the AI would be to either use Unity’s navmesh or incorporate a third-party pathfinding solution like simple path. An option to have the AIs select random points to wander to would also be a good addition.

    The current AI uses waypoints that define a patrol path which they follow until they see the player. If the Do Patrol check box of the AI.js script is not clicked, they simply stand watch until they see the player. When the player is in view, they run after the player and attack, but once their line of sight is blocked, they walk back to their patrol path or original position.

    To turn the current enemies into melee attacking zombies, you first need to change the Shoot Range and Dont Come Closer Range values in the AI.js script instance of the enemy object to 2.

    In the next update, that’s all that you’ll need to do, but the current version, you also need to change the AI.js script starting at line 113 from:

    Code (csharp):
    1.             if(distance > shootRange * 3){
    2.                 speedAmt = 1.0f;
    3.                 return;
    4.             }
    to

    Code (csharp):
    1.             if(distance > attackRangeAmt){
    2.                 speedAmt = 1.0f;
    3.                 return;
    4.             }  
    And the enemy will run up close before they start attacking. The Attack Range value determines at what range they will see the player and start attacking. Maybe I will include melee enemies in a future update, all that's needed is a zombie model with a melee attack animation and a different sound effect.
     
    Last edited by a moderator: Apr 7, 2013
  13. TheRealFuzz

    TheRealFuzz

    Joined:
    Jul 17, 2012
    Posts:
    308
    Thanks for getting back to me. I just tested the example that came with this asset and I can confirm that objects slowly fall down in the example scene. I've check all the values that you've suggested and still no luck, I'll keep searching and see if I can fix it.
     
  14. Deleted User

    Deleted User

    Guest

    I see what the problem is now. The Drag Rigidbody script increases the drag of an object when you pick it up so it won't spin around excessively when you move the mouse. The script usually changes the drag back to it's original value, but for some reason it's missing that step, or overwriting the original drag value and the object is keeping the high drag value (10 by default). I've never seen this happen until I was working on something else with this script. Really sorry about this. I've checked for, and fixed all the problems I could find, but this is one of those bugs that is hard to track down because it shows up somewhat randomly. I'll let you know once I find a fix, so you won't have to wait for the update.
     
  15. TheRealFuzz

    TheRealFuzz

    Joined:
    Jul 17, 2012
    Posts:
    308
    Thank you very much! Looking forward to it :)
     
  16. Deleted User

    Deleted User

    Guest

    No problem, thank you for letting me know about the issue!

    Ok this should fix two bugs in the DragRigidbody.cs script. The next update will include these fixes, but you can apply them now if you want. Be sure to back up the original DragRigidbody.cs script before making these changes in case you make a mistake. It's also important to follow these steps in the order they are posted because I will be referring to line numbers.

    First, around line 16 change:

    Code (csharp):
    1. private float oldDrag;
    2. private float oldAngularDrag;
    3.    
    4. void Update (){
    to:

    Code (csharp):
    1. private float oldDrag;
    2. private float oldAngularDrag;
    3. private bool dragState;
    4.    
    5. void FixedUpdate (){
    then, around line 27, change:

    Code (csharp):
    1.     RaycastHit hit;
    2.     if(!Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, reachDistance)){
    3.         return;
    4.     }
    to:

    Code (csharp):
    1.     RaycastHit hit;
    2.     if(!Physics.Raycast(Camera.main.transform.position, ((Camera.main.transform.position + Camera.main.transform.forward * reachDistance) - Camera.main.transform.position).normalized, out hit, reachDistance)){
    3.         return;
    4.     }
    then, around line 61 change:

    Code (csharp):
    1.  
    2. IEnumerator DragObject ( float distance  ){
    3.     oldDrag = springJoint.connectedBody.drag;
    4.     oldAngularDrag = springJoint.connectedBody.angularDrag;
    5.     springJoint.connectedBody.drag = drag;
    6.     springJoint.connectedBody.angularDrag = angularDrag;
    to:

    Code (csharp):
    1. IEnumerator DragObject ( float distance  ){
    2.     if(!dragState){
    3.         oldDrag = springJoint.connectedBody.drag;
    4.         oldAngularDrag = springJoint.connectedBody.angularDrag;
    5.         dragState = true;
    6.     }
    7.     springJoint.connectedBody.drag = drag;
    8.     springJoint.connectedBody.angularDrag = angularDrag;
    then, around line 69 change:

    Code (csharp):
    1.         Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
    2.         springJoint.transform.position = ray.GetPoint(distance);
    3.         if(!Input.GetKey(KeyCode.X)){
    to:

    Code (csharp):
    1.  
    2.         Ray ray = new Ray (Camera.main.transform.position, ((Camera.main.transform.position + Camera.main.transform.forward * reachDistance) - Camera.main.transform.position).normalized);
    3.         springJoint.transform.position = ray.GetPoint(distance);
    4.         if(!Input.GetKey(KeyCode.X)){
    and finally, around line 107 change:

    Code (csharp):
    1.     springJoint.connectedBody.angularDrag = oldAngularDrag;
    2.     springJoint.connectedBody = null;  
    to:

    Code (csharp):
    1.     springJoint.connectedBody.angularDrag = oldAngularDrag;
    2.     springJoint.connectedBody = null;
    3.     dragState = false;
    If all went well, the script should compile and you should be able to start the scene in the editor and be able to drag rigidbodies without needing to left click outside the running game window and back in it again. This should also fix the rigidbody drag not being set to its original values when you let go of an object.

    Also note that the first Raycast doesn't use a layer mask and is checking all layers for hits. In the next update, this Raycast will be using a layermask. For efficiency it will only check objects that can be picked up. I excluded that part of the code to make this fix easier to apply.

    If the rigidbodies are still falling slowly or the script doesn't work, please copy the backup DragRigidbody.cs back over your modified script, and let me know so I can keep looking at the code, but I'm pretty sure this solves both problems.
     
  17. TheRealFuzz

    TheRealFuzz

    Joined:
    Jul 17, 2012
    Posts:
    308
    Thanks for going to all the trouble but I couldn't get the script to work but I'm sure it works on your end, as you can probably tell, I'm not much of a coder :p

    Would it be to much to ask for you to PM me the edited script? Otherwise I can wait for the next update.
     
  18. jonkuze

    jonkuze

    Joined:
    Aug 19, 2012
    Posts:
    1,709
    hey Azuline, I just purchased this Asset on Saturday! I was as impressed with it as I was when i saw the demo and asset features. Really Awesome man! One of my best Asset purchases to Date I must say. THANK YOU! for the above fix to turn the AI into Melee Attacking Zombies! = )

    I have a game called ZombieWarz... http://zombiewarz.com that uses Ultimate FPS Camera and a Zombie Asset, I was thinking of updating the Game using your Asset! So this Fix will be very helpful for me to at least get some Zombies in the game to see what it looks like... later I'll try to update the AI unless you manage to update the AI before I do lol. = ) anyway thanks again! awesome job on this asset and support.
     
  19. Deleted User

    Deleted User

    Guest

    PM sent. Hope the updated script works better for you TheRealFuzz!

    Thank you Kuroato! Really glad that you've been enjoying the asset. A lot of time and effort has been put into this project :)

    We'll see about improving the AI, there are a few other features we're looking at first though. The AI really only needs some pathfinding added to it. The enemies work surprising well for just having linear paths to their goals. They can get stuck behind walls sometimes, but I think it helps that they have round capsule colliders as it helps them get around corners. Best of luck on your project!
     
  20. aeditz50

    aeditz50

    Joined:
    Dec 18, 2012
    Posts:
    10
    Is it possible to add your own guns?
     
  21. SkyCone131

    SkyCone131

    Joined:
    Apr 8, 2013
    Posts:
    1
    This FPS kicks a**!! Definitely, the best one on here - hands down. Great job! Appreciate the support and looking forward to the update.
     
  22. Unicron

    Unicron

    Joined:
    Sep 28, 2011
    Posts:
    191
    Wouldn't be of any use if you couldn't. Should be the same as any other FPS kits out there, gotta make sure you have the correct assets, weapon model, sounds, animations, etc.

    I'm liking this kit a lot but I'll wait it out to see what's added in the next updates, it's a few features short of perfect. Features I'd like to see added in the next updates are lean left/right, stamina, swimming (if not already in), damage handler (didn't see that listed in the features list), jumping/vaulting/climbing/hanging over obstacles (not ladders), weapons with scopes, dual wielding items/weapons,etc.
     
    Last edited: Apr 8, 2013
  23. Deleted User

    Deleted User

    Guest

    Adding your own guns to the Realistic FPS Prefab is a simple process and just involves duplicating an existing weapon object, swapping out the model for one of your own, and tweaking the values of the weapon script. You can also chose to configure weapon and ammo pickups for the new weapon. Just did this for the new sniper rifle in version 1.1 and the process was pretty quick. There is a detailed tutorial in the documentation that walks you through the steps. We are also here to answer any questions you might have involving this process.

    Thank you! We're glad that you're enjoying the asset!

    Thanks Unicron, there is player damage handling done in this asset that comes into play when you fall a long distance, are hit by enemy fire, or are caught under an elevator, etc. We're updating our feature list to make this more clear. As far as scoped weapons, it's only a matter of having a weapon model with a scope ready to be imported into Unity. We just added a sniper rifle in the new update to demonstrate how scopes work in this asset. The camera zoom amount and zoomed weapon sway amount can be customized to make adding scoped weapons a quick process. Most of the other features you mentioned are on the way. If you have any questions, please let us know!


    The new Realistic FPS Prefab 1.1 update is being uploaded today and should be live soon. It adds a sniper rifle and involves a few minor fixes of the AI and rigidbody dragging code as well as the addition of configurable controls from the inspector and two new variables to customize zoomed and unzoomed weapon sway for each weapon (useful for scoped weapons or other kinds of optics). Here are the specific changes for version 1.1:

    -Added a sniper rifle and pickups to demonstrate scoped weapons.
    -Attack Range variable of AI.js is now properly taken into account for determining when to attack the player.
    -Fixed raycast calculation in DragRigidbody.cs so user won’t have to click outside and back in the running game window in the editor to drag rigidbodies.
    -Fixed rigidbodies keeping high drag values resulting in objects falling slowly.
    -Controls can now be easily set from the inspector in the FPSPlayer.cs script on the FPS Player object
    -Added swayAmountZoomed variable to WeaponBehavior.cs to control zoomed weapon sway which can be used for reducing the zoomed sway of scoped weapons.
    -Added swayAmountUnzoomed variable to WeaponBehavior.cs to allow customization of unzoomed sway amount for individual weapons.
    -Miscellaneous inspector visibility cleanup.​
     
  24. wheelbarrow

    wheelbarrow

    Joined:
    Sep 12, 2011
    Posts:
    177
    Hi guys, I picked up the asset yesterday, and am very happy with it, but I have a couple of questions: anything special to watch regarding installing the upgrade - i.e. will it import over the earlier version ok or do I have to remove the older version before bringing 1.1 in? I'm using Unity Pro version 4.1.1f4.

    Secondly, I am about to bring my enemies into my scene, and they have an apply damage script, but it looks for projectile object tag names to decide if it causes damage, and how much etc - I can't find any projectiles in this asset (apart from the ejection shells), so is it all raycast, and if so, whats the best way for me to tell my enemy it has been hit? The apply damage script is part of a larger ai script, so I can't really remove it without screwing everything else up. Thanks guys, and good job on the asset.
     
  25. Deleted User

    Deleted User

    Guest

    Thanks wheelbarrow, glad you’re enjoying the Realistic FPS Prefab! As far as what to watch for when installing the update, it depends on what changes you’ve made to the scripts and objects in version 1.05. When you click the import button for the updated package in the asset store download manager, it will show you which files have changed in the update before giving you a chance to import them over your current files to upgrade the asset to 1.1.

    If you have changed many of those files, you might want to import the updated Realistic FPS Prefab 1.1 into an new empty project (keeping your modified project that uses 1.05) and then use a third party tool like WinMerge to view the differences between the version 1.1 scripts and your modified versions from 1.05. WinMerge will let you see where we made changes in the script for the update so you can decide how to add your code from the previous version’s script into the new version’s script.

    We mention the names of the scripts that were modified in the version notes to assist in tracking down where to plug in your changes in the new version, but if you have any requests, like a list of specific files that were changed in the new version, we can provide that for you as well.

    As for telling your enemy that it’s been hit, the WeaponBehavior.cs script has a function around line 740 called:

    Code (csharp):
    1.  
    2. void HitObject ( RaycastHit hit, Vector3 direction ){
    which is called when the raycast from the weapon hits an enemy collider. In that function physics force is applied to rigidbodies hit by the weapon’s raycast, and the enemy’s ApplyDamage function is called like this:

    Code (csharp):
    1.         //Call the ApplyDamage function in the hit object          
    2.         hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver);
    So from what you’ve described, it sounds like a raycast hit from the asset’s weapons should be able to call your AI script’s ApplyDamage function, if that’s the exact, case sensitive name of your function as well. If your AI script’s ApplyDamage function isn’t getting called, then you might want to look at the HitObject function in WeaponBehavior.cs and make sure that the function is using the same name in the SendMessageUpwards call, and that your script is attached to the same game object as the collider component that’s hit by the raycast.

    Please let us know if you still have questions on how to call the damage function of your AI script.
     
  26. kenlem

    kenlem

    Joined:
    Oct 16, 2008
    Posts:
    1,630
    How easy would it be to add input support for mobile devices? Are the input routines in one location or are they sprinkled through the code?
     
  27. wheelbarrow

    wheelbarrow

    Joined:
    Sep 12, 2011
    Posts:
    177
    Thanks, I got it figured out, and now the damage problem is sorted, but it leads to another one (sorry) : I have my enemies on the NPCs layer, which is supposed to be masked from the bullets according to weapon behaviour cs, but I have bullet holes appearing on the box collider on my npc. The only difference I see between your robots in your demo scene, and my npc, is you use a character controller, and I use a rigidbody, which my ai uses to move the npc's, and a box collider (I can't use a cc, it screws up the ai ). How do I get rid of the bullet holes if the npc is already on the bullet mask layer? Thanks, and sorry to be a bother.
     
  28. Deleted User

    Deleted User

    Guest

    In version 1.1, the input key assignments are all centralized in the FPSPlayer.cs script, but the actual Input.GetKey calls are located at places in the other scripts where they are needed as part of other behaviors. If you were going to add input for mobile devices, I imagine it would be as simple as swapping the input key assignments in FPSPlayer.cs for the button/virtual pad controls of your mobile input system.

    If you needed an input call other than Input.GetKey, then you might have to go through the scripts and swap them out, but it shouldn't be too complicated if you right click on an Input.GetKey or Input.GetKeyDown reference in MonoDevelop and click on the Find References option to bring up a window of all the Input.GetKey calls used in the asset. Then it's only a matter of clicking on the entries in the Search Results window and MonoDevelop should take you right to them where you could paste over your own input calls.

    There are about 40 Input.GetKey calls and 15 Input.GetKeyDown calls in the scripts. We can offer advice and support if you need help changing the input method used in the project.

    No problem wheelbarrow! The bullet mask layer is only for telling the weapon raycast to check that object for a collision. This asset uses tags to determine whether or not to leave hit marks on an object. Have you tried setting the game object tag of your enemies to NoHitMark? That tells the WeaponBehavior.cs script to not put hit marks on that object. If you need your NPC to have a different tag than NoHitMark, then you can add a check for MyExampleTag in the BulletMarks function in the WeaponBehavior.cs script around line 1004 like this:

    Code (csharp):
    1.     void BulletMarks ( RaycastHit hit  ){
    2.         if(hit.collider//check only objects with colliders attatched to prevent null reference error
    3.          hit.collider.gameObject.layer != 9//don't leave marks on ragdolls
    4.          hit.collider.gameObject.tag != "NoHitMark"//don't leave marks on active NPCs or objects with NoHitMark or PickUp tag
    5.          hit.collider.gameObject.tag != "PickUp"
    6.          hit.collider.gameObject.tag != "MyExampleTag"){
    Hope that helps you with your NPC/BulletMark problem.
     
    Last edited by a moderator: Apr 12, 2013
  29. Unicron

    Unicron

    Joined:
    Sep 28, 2011
    Posts:
    191
    Can the pickup system be modified so that instead of picking up the item right away you can set it to give an option when clicked to pickup (put in inventory), use, equip, destroy, etc.

    Also can the drag object be modified so that you don't have to hold the z key and instead press once to pickup and drag and press again to drop?
     
  30. Deleted User

    Deleted User

    Guest

    Hi Unicron, the pickup system can be modified however you see fit. We've had a few requests to add an option for a system like the one you described where the player taps the use button once to pick up the object, and again to drop the object. So I will be looking into adding this for a future update.

    The current system works by adding a spring joint on the object where the crosshair is currently positioned. This allows you to grab the corner of a physics object and spin it relative to the rest of the object. For the method like you described, I'm considering just modifying the position of the object itself. The DragRigidbody.cs script would also need a simple toggle behavior added to it to handle the button presses.

    Also, in the next update, the option to have pickups stay after being used (instead of disappearing) will be added to allow for the creation of resupply rooms and such.

    This thread will be updated as progress is made on new features, but feel free to ask for advice if you want to try implementing the system sooner on your own.
     
    Last edited by a moderator: Apr 13, 2013
  31. kerryenfinger

    kerryenfinger

    Joined:
    Jan 22, 2013
    Posts:
    14
    Bought the Realistic FPS Prefab last night. Excellent resource!!! Do you have any idea when version 1.1 will go live on the Asset Store? It still shows version 1.05.
     
  32. Deleted User

    Deleted User

    Guest

    Thanks kerryenfinger, Version 1.1 should be going live in a few days. It's still going through the Unity review process. We're glad you're enjoying the asset!
     
  33. hellraizerhhh

    hellraizerhhh

    Joined:
    May 26, 2010
    Posts:
    619
    Guns need a bit of work to feel realistic. Currently the manipulation of the weapons is really weak. The character barely moves his hand and the shotgun loads. Realistically it would take much more energy and a further pull to eject and load a new shell. The MP5 cocking handle is manipulated so softly it stands out as nowhere near realistic. You have to hit the charging handle down for it to slide forward with force. As far as the AK, you have the character ejecting the magazine and hes not even using the magazine release, how did he take it out? The Katana was the worst offender. Hes just stand there and swings from the idle position. There is no transfer of energy or momentum. If you wield a sword you will notice that you would have to pull it back to build the needed energy to strike down (in animation this is anticipation). You would then strike down and have the energy transfer through and continue for a bit as the momentum stops (this is called overlap and follow through)

    Ultimately I'm just trying to say that the guns and sword are working nowhere as they would in real life. Once they are tweaked it will feel much nicer
     
    Last edited: Apr 14, 2013
  34. salad__fingers

    salad__fingers

    Joined:
    Aug 11, 2012
    Posts:
    42
    How do you make it to where you spawn with a gun?
    Cheers.


    EDIT
    Nevermind, I found it.
    For anyone else with this, simply tick "Have Weapon" on the weapon game object. Then, go to FPS Weapons, and change First Weapon to the number of the weapon you chose. For example if you want to spawn with an AK47, click AK47, tick Have Weapon, go to FPS Weapons, and then type in 5 for first weapons.
     
    Last edited: Apr 14, 2013
  35. Deleted User

    Deleted User

    Guest

    hellraizerhh, we'll definitely consider your feedback on the weapon animations when we get the chance. Thank you.

    Glad you were able to figure this out salad__fingers! We made the First Weapon variable so you can choose which weapon to spawn with and it is also a variable you would want to store in memory or a save game file if the player was changing scenes/areas and you wanted them to keep the same weapon they had equipped from the previous map. Let us know if you have any more questions.


    Some notes on our recent progress improving the asset:

    Pausing the game

    We've recently incorporated a fix to our code that allows the game to be paused by setting Time.timeScale to 0 and back to a positive value. 1.1 and earlier versions don't have this fix incorporated yet and will display NaN errors from the Mathf.SmoothDamp functions when changing the value of Time.timeScale to zero and back to a positive value. Here are the modifications that we made to our code to allow pausing by changing the value of Time.timeScale.

    What's required is to enclose the actions of a few scripts in if(Time.timeScale > 0){ checks. Specifically line 54 of SmoothMouseLook.cs should be changed to:

    Code (csharp):
    1. if(Time.timeSinceLevelLoad > 1  Time.timeScale > 0){
    The Update() code of Ironsights.cs starting around line 115 should be enclosed in a if(Time.timeScale > 0){ check.

    The Update() code of Gunsway.cs starting around line 58 should be enclosed in a if(Time.timeScale > 0){ check.

    And both the Update() and FixedUpdate() code of WeaponBehavior.cs should be enclosed in if(Time.timeScale > 0){ checks.

    This should allow you to pause the game by setting Time.timeScale to 0. If you're having trouble, feel free to contact us and we can send you the fixed scripts.



    Shotgun Reloading

    The shotgun reloading method (non magazine reloading) used in our asset is a bit more complex than the technique used for reloading by magazine. We're going to be updating our documentation in a future update to help explain how the weapon animations work for shotguns or other weapons where you want the player to reload them one bullet/shell at a time. But for now, here is a description of how our shotgun reloading animations work:

    Shotgun reloading takes some extra programming, but we tried to make it to be as simple as possible in the asset. Our demo shotgun has one shooting animation and one continuous reloading animation where hand goes from neutral, to loading a shell, back to neutral, and then pumping the shotgun.

    We tell unity that the first frame of the reload animation starts when the hand is already loading the shell. So the weaponMesh.animation.CrossFade() call of the script is actually filling in/interpolating the frames from when the hand starts to move toward the shell loading port from the original position.

    Then Unity just loops the reloading animation until the last shell is reloaded, where the whole last part of the animation (pumping the shotgun) is allowed to play. We also define a Neutral animation of the hand going from the reload port back to neutral (without pumping) for when shotgun reloading is interrupted and not allowed to finish by another action like sprinting or shooting.

    So if your shotgun reload animation has reload start, loading a bullet/shell, and finish reload animations in that sequence in the model, you can set the Reload animation's start frame in the model's import settings to the first frame of the loading a bullet/shell animation and set the last frame of the Reload animation to the last frame of your finish reload animation including the shotgun pump/chambering animation if your animations have one.

    You would then want to define the Neutral animation to be the frames of your reload animation where the hand is returning to the firing position after inserting the shell so reload animation interruptions will be smooth and continuous. Then you could set the Ready animation frame range to be the frames where the hands pump the shotgun.

    The weaponMesh.animation["Reload"].speed = 0.7f; line of code in WeaponBehavior.cs around line 929 determines the animation speed of how quickly the bullet loading part of the reloading animation is played when it's being looped during reloading. So 0.7f can be changed to whatever looks smoothest for your reload animation (we slowed it down to 0.7 from 1.0). This will be added as a customizable variable per-gun in a future update.
     
  36. OneShotGG

    OneShotGG

    Joined:
    Nov 16, 2012
    Posts:
    225
    Just purchased the pack and I really think it is top quality (anxiously awaiting the new patch though :p ).

    The question I have pertains to animation. What program did you use to animate the arms and guns? I need to do some custom animations (reloading different locations like c96, lugar, etc , and revolver animations) and when I loaded the m1911anim.fbx file into 3dsmax the hands were all messed up (the animations went though though).
     
  37. Deleted User

    Deleted User

    Guest

    Thanks OneShotGG! The program we used to animate the arms and guns is Maya. Importing the .FBX into Maya should maintain the object hierarchies and bone weights/skin cluster output for the arm bones and allow you to see how the animations work. If you have any other questions, please let us know.




    In other news, yes, we know our asset store link is down. We hope to have it back up soon.

    Sorry for the inconvenience​
     
    Last edited by a moderator: Jan 30, 2019
  38. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    Yes, I've tried to download the new 1.1 version, but link is down :( why, what happend? :eek:
    I hope it will be back because I love that asset, I'll stand by. When will it be back, do you know maybe?

    Oh, almost forgot: AK47 and MP5 won't shoot? :S (no animation, no projectile and no bullet marks of course)
    It says some errors in script WeaponBehaviour: Line: 183, 228 and 685
    Some animations problems as I saw

    Please help me!
     
    Last edited: Apr 17, 2013
  39. OneShotGG

    OneShotGG

    Joined:
    Nov 16, 2012
    Posts:
    225
    Yeah, I figured it out :p. I actually have a Luger model in the game now and working with tweaked animations (I am not an animator but I know enough to be dangerous...lol)

    I'll take a youtube of how it looks once I get the texture done the way I like it. (PS yalls documentation is very good, had no problems once I started following that ;) )
     
  40. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    Heh, any idea how to fix it? :(
    I need those machine guns! (love them) :D
     
  41. Deleted User

    Deleted User

    Guest

    Great job OneShotGG. We did try to make the documentation as helpful as possible. Glad you got everything working! Looking forward to your video :)

    Sorry for the inconvenience Dari, the link should be back up soon.

    For the weapon errors, can you give us some additional details about what's happening. First of all, are you you trying to run the demo scene, or a new scene? If you are trying to run the demo scene, have you changed anything from the default configuration of the FPS Prefab? From the errors you were mentioning, it sounds like the weapon object is having problems finding its parent sprinting animation, which might mean that the weapon object is out of the hierarchy that it needs to communicate to the rest of the prefab.

    We've done a lot of testing and the FPS Prefab should work just by dragging it into a scene with its default settings, but if the weapon parent/child hierarchies are misconfigured, then you can click on the !!!FPS Main object in the Hierarchy window and then click on the middle "revert" button on the Prefab row in the inspector. This will revert any changes that have been made to the prefab to default, unless you clicked the "apply" button at some point and stored a state other than the default. In that case, you'd want to restore the backup "!!!FPS Player Main Original" prefab from the !Realistic FPS Prefab Files/!Objects folder. If you have done a lot of work, you might want to save your progress in a separate scene before trying this.

    You might also want to check out the documentation if you haven't already to get a better idea of how the gameobjects that make up the FPS Prefab communicate with the scripts. If you are still having problems, would you please describe again step-by-step what you are experiencing so we can track down the cause? Thank you.
     
  42. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    1. I'm trying demo and my scene and it's still the same. (won't work, the guns)
    2. I didn't change anything in demo scene, still won't work.
    3. When I play, other guns are working fine expect these two (AK47 and MP5)
    4. When I collect the weapon AK47/MP5 then in debug it says: NullReferenceException (it happens in gameplay)
    5. When the game is paused/quit in debug it says following errors:

    WHEN I COLLECT THE WEAPON IT SAYS THESE TWO ERRORS:
    NullReferenceException
    WeaponBehavior.Start () (at Assets/!Realistic FPS Prefab Files/Scripts/Weapons/WeaponBehavior.cs:183)

    NullReferenceException
    WeaponBehavior.OnEnable () (at Assets/!Realistic FPS Prefab Files/Scripts/Weapons/WeaponBehavior.cs:228)
    UnityEngine.GameObject:SetActive(Boolean)
    <SelectWeapon>c__Iterator6:MoveNext() (at Assets/!Realistic FPS Prefab Files/Scripts/Weapons/PlayerWeapons.cs:255)

    BUT WHEN I SHOOT THE BULLET IT SAYS THIS ERROR:
    NullReferenceException
    WeaponBehavior+<FireOneShot>c__Iterator8.MoveNext () (at Assets/!Realistic FPS Prefab Files/Scripts/Weapons/WeaponBehavior.cs:685)
    UnityEngine.MonoBehaviour:StartCoroutine(String)
    WeaponBehavior:Fire() (at Assets/!Realistic FPS Prefab Files/Scripts/Weapons/WeaponBehavior.cs:649)
    WeaponBehavior:Update() (at Assets/!Realistic FPS Prefab Files/Scripts/Weapons/WeaponBehavior.cs:551)

    That's all, I've also tried to revert the !!!FPS Player Main and didn't worked.
    Thanks for helping me, wish you the best luck!

    I'm really sorry if I am asking too much, it's because I don't know much about scripting, that's the hardest for me.
    I'm only 12 years old...

    Please answer as soon as possible, thank you.
     
    Last edited: Apr 19, 2013
  43. Deleted User

    Deleted User

    Guest

    No problem Dari, thanks for the detailed report. The first clue is that the other guns are working fine except the AK47 and MP5. This leads me to believe that something about the default setup involving those guns has changed, not downloaded correctly, or not initialized as it's designed to.

    The errors in WeaponBehavior.cs all seem to be tied to setting the animation speeds of the view weapon mesh, which happens when you pick up or select the weapon (ready animation speed) and when you fire the weapon (fire animation speed) like you described. The fact that you're getting null reference errors might point to the fact that the WeaponBehavior.cs instances for those weapons don't have their WeaponMesh value set to the weapon model object underneath them in the hierarchy.

    The Animation component of the MP5_Anim and AK47_Anim objects should also have 3 entries; Fire, Reload, and Ready, that use the imported animations from the _Anim meshes.


    The first thing I'd suggest is to get version 1.6 of our asset and make sure everything has downloaded and unpacked correctly and then try out the demo scene without modifying any settings.

    If you still get the errors, could you please take a screen shot of the scene when it's running so the hierarchy window is visible with the !!!FPS Main/FPS Weapons/MP5 object selected so the top of the MP5's WeaponBehavior.cs script instance is visible in the inspector window? That should let me know if your FPS Weapon hierarchy is intact and if the WeaponBehavior.cs instance is configured correctly.

    We're sorry you're running into problems. Thanks for your patience!
     
    Last edited by a moderator: Apr 20, 2013
  44. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    668
    Hi Azuline,

    Noticed it hasn't been asked yet, but was wondering if there was any way to use your climbing, gun and pickup code with the Ultimate FPS Camera, or if it's just too tied to your own camera? My background is design/art, so coding knowledge is extremely limited.

    If it's something that would require you to have a copy of Ultimate FPS Camera to accomplish, I don't mind sending you the funds to purchase it through PayPal, if it will result in something usable, or at the very least result in a tutorial everyone can follow to do this.

    Please advise.
     
  45. OneShotGG

    OneShotGG

    Joined:
    Nov 16, 2012
    Posts:
    225
    Quick couple of questions...

    1. What would be the best way to limit the player to two weapons (like COD Zombies).

    2. I have a magic casting system (Js) that I have integrated into your prefab. I need to be able to call the current weapon in order to play the spell casting animation. I have look through your scripts and cannot find a "current weapon" variable or class. How are yall calling the current weapon?
     
  46. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    Still not working. I've downloaded the new 1.16 version but these two guns works same.

    ERRORS:


    When I collect the weapon:

    NullReferenceException
    WeaponBehavior.Start () (at Assets/!Realistic FPS Prefab Files/Scripts/Weapons/WeaponBehavior.cs:186)

    NullReferenceException
    WeaponBehavior.OnEnable () (at Assets/!Realistic FPS Prefab Files/Scripts/Weapons/WeaponBehavior.cs:231)
    UnityEngine.GameObject:SetActive(Boolean)
    <SelectWeapon>c__Iterator6:MoveNext() (at Assets/!Realistic FPS Prefab Files/Scripts/Weapons/PlayerWeapons.cs:259)

    When I shoot with them:

    NullReferenceException
    WeaponBehavior+<FireOneShot>c__Iterator8.MoveNext () (at Assets/!Realistic FPS Prefab Files/Scripts/Weapons/WeaponBehavior.cs:694)
    UnityEngine.MonoBehaviour:StartCoroutine(String)
    WeaponBehavior:Fire() (at Assets/!Realistic FPS Prefab Files/Scripts/Weapons/WeaponBehavior.cs:658)
    WeaponBehavior:Update() (at Assets/!Realistic FPS Prefab Files/Scripts/Weapons/WeaponBehavior.cs:559)


    SCREENSHOTS:

    Screenshot 1:
    $UnityFPS03.JPG

    Screenshot 2:
    $UnityFPS205.JPG

    Screenshot 3: (Gameplay mode)
    $UnityFPSgame04.JPG

    Maybe I should make a video? Thanks for your patience!
     

    Attached Files:

    Last edited: Apr 21, 2013
  47. lebid

    lebid

    Joined:
    Nov 17, 2012
    Posts:
    30
    hummm .... No error with version 1.05 and 1.16 for me
     
  48. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    MP5 and AK47 are working good?
    I would say that something isn't working good with my Unity or something like that, I hope that Asset is very nice and working fine for others. :)
     
  49. Deleted User

    Deleted User

    Guest

    There was some discussion between us and TheRealFuzz about porting our climbing code in this post. Our movement and weapon scripts are pretty integrated into our asset, but with some study of both code bases, I'm sure something could be achieved by people who own both assets.

    As far as making elements of the two assets interchangeable out of the box, we can see how that would be great for you guys, but it really starts to go into a grey area license-wise because these are copyrighted commercial products being sold on their own merits. We don't have the rights to publish or sell copyrighted code from other projects and vice versa, so it would be up to the customers who have purchased both assets as to what they do individually with them.

    What we can do is provide information and support on what parts of our code can interface with other scripts. We just assisted a customer in changing our Input.GetKey calls to mobile touch button inputs using the 2D Toolkit, for example. I hope this answers your question.


    Great questions OneShotGG. To limit the player to two weapons, you could create a variable like maxWeapons and a check for this variable in the SelectWeapon() function in PlayerWeapons.cs that doesn't allow the player to pick up new weapons if their totalWeapons is greater than the maxWeapons amount already. To track the totalWeapons amount, you could write a for statement in PlayerWeapons.cs that iterates through all weapon objects in the WeaponOrder array to see if the haveWeapon value of their WeaponBehavior.cs instance is set to true, and if so, add it to the totalWeapons var. There would also need to be an initialization check in the Start() code so totalWeapons doesn't exceed maxWeapons. That's not a perfect explanation, but that describes how I'd approach it.

    The current weapon number is stored in the childNum variable of PlayerWeapons.cs. We should probably change the name to something more obvious like currentWeapon. The value of childNum corresponds to the current weapon's array index number in the WeaponOrder array. childNum is a public var, but it's hidden from the inspector because it's handled at runtime by PlayerWeapons.cs

    We will be adding droppable weapons soon and it would make sense for us to add the max weapons feature at the same time since it involves changing PlayerWeapons.cs. If you have any problems implementing it on your own, let us know and we'll help you.


    Well, from what I can see in the screenshots, it looks like the FPS Prefab is set up correctly. The errors you are having are pointing to the animation speed calls. The first thing I would suggest doing is commenting out or typing "//" at the beginning of the lines 694 and 186 which have the weaponMesh.animation["Fire"].speed = fireAnimSpeed; calls in WeaponBehavior.cs and then test the scene to determine if the errors stop, or if they occur on different lines.

    If the errors do stop, then you can leave those lines commented out. If not, could you post the errors that happen after the lines are commented out?

    You also can read the tutorial on adding new weapons and create a new weapon by duplicating a weapon object, dragging a new instance of the AK47_Anim or MP5_Anim model from the library over the duplicated object so it becomes a child of the weapon object, along with the other steps from the tutorial. If the errors happen on your new weapon, try switching out the MP5_Anim or AK47_Anim model with an _Anim model from one of the other working weapons and see if the errors still happen.


    Thanks lebid, we're trying to recreate the problem Dari's describing without any luck. Hopefully what we suggested above will give us some more info!
     
    Last edited by a moderator: Apr 21, 2013
  50. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    It shoots but no animation :D

    When I collect the weapon:

    NullReferenceException
    WeaponBehavior.Start () (at Assets/!Realistic FPS Prefab Files/Scripts/Weapons/WeaponBehavior.cs:187)

    NullReferenceException
    WeaponBehavior.OnEnable () (at Assets/!Realistic FPS Prefab Files/Scripts/Weapons/WeaponBehavior.cs:231)
    UnityEngine.GameObject:SetActive(Boolean)
    <SelectWeapon>c__Iterator6:MoveNext() (at Assets/!Realistic FPS Prefab Files/Scripts/Weapons/PlayerWeapons.cs:259)

    When I shoot:

    The animation state Fire could not be played because it couldn't be found!
    Please attach an animation clip with the name 'Fire' or call this function only for existing animations.
    UnityEngine.Animation:CrossFade(String, Single, PlayMode)
    <FireOneShot>c__Iterator8:MoveNext() (at Assets/!Realistic FPS Prefab Files/Scripts/Weapons/WeaponBehavior.cs:695)
    UnityEngine.MonoBehaviour:StartCoroutine(String)
    WeaponBehavior:Fire() (at Assets/!Realistic FPS Prefab Files/Scripts/Weapons/WeaponBehavior.cs:658)
    WeaponBehavior:Update() (at Assets/!Realistic FPS Prefab Files/Scripts/Weapons/WeaponBehavior.cs:559)

    It says some errors when I reload the guns:

    NullReferenceException
    WeaponBehavior.FixedUpdate () (at Assets/!Realistic FPS Prefab Files/Scripts/Weapons/WeaponBehavior.cs:347)

    NullReferenceException
    WeaponBehavior+<Reload>c__Iterator9.MoveNext () (at Assets/!Realistic FPS Prefab Files/Scripts/Weapons/WeaponBehavior.cs:860)
    UnityEngine.MonoBehaviour:StartCoroutine(String)
    WeaponBehavior:FixedUpdate() (at Assets/!Realistic FPS Prefab Files/Scripts/Weapons/WeaponBehavior.cs:343)

    By the way, hadn't got too much time so I didn't tried the second example to fix the weapons (one where I have to recreate the weapons).

    Sorry about that.
     
    Last edited: Apr 21, 2013