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. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    578
    works on current version too in unity 5 i tryed xd
     
  2. Takahama

    Takahama

    Joined:
    Feb 18, 2014
    Posts:
    169
    lol xD
     
  3. NeuroToxin-Studios

    NeuroToxin-Studios

    Joined:
    Dec 7, 2014
    Posts:
    68
    Ok just tested and yes this does actually happen :/, this will be a problem for me as my scene has a lot of physics object littering the floor etc and at one point the character needs to crouch. Might have to look into the scripts and see if I can tweak anything
     
  4. TechSinsN

    TechSinsN

    Joined:
    Apr 12, 2014
    Posts:
    121
    MissingComponentException: There is no 'Rigidbody' attached to the "Pickup_Ump(Clone)" game object, but a script is trying to access it.
    You probably need to add a Rigidbody to the game object "Pickup_Ump(Clone)". Or your script needs to check if the component is attached before using it.
    UnityEngine.Rigidbody.AddForce (Vector3 force, ForceMode mode) (at C:/buildslave/unity/build/artifacts/EditorGenerated/NewDynamics.cs:666)
    PlayerWeapons.DropWeapon (Int32 weapon) (at Assets/!RFPSP/Scripts/Weapons/PlayerWeapons.cs:324)
    WeaponPickup.PickUpItem () (at Assets/!RFPSP/Scripts/Items/WeaponPickup.cs:50)
    UnityEngine.Component:SendMessageUpwards(String, SendMessageOptions)
    FPSPlayer:FixedUpdate() (at Assets/!RFPSP/Scripts/Player/FPSPlayer.cs:512)

    So i changed the weapon and it works fine but when i go to swap it for a different weapon i get this error and i can't seem to find a fix for it. so any help is great
     
  5. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Check your weapon's Weapon Drop Obj. This should point to a prefab. Make sure the prefab has a rigidbody.
     
  6. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    What a neat exploit! :)

    When you stand from a crouch, the player's collider immediately expands vertically from the crouched height to the standing height. This puts a lot of downward force under the player. Since the physics object has a rigidbody, you get an equal and opposite upward force, jettisoning the player into the air.

    If you want to fix it, edit FPSRigidbodyWalker.cs. Around line 880, in the "//Crouching & Prone" section of FixedUpdate(), change this line:
    Code (csharp):
    1. capsule.height = standingCapsuleheight;
    to this:
    Code (csharp):
    1. if (capsule.height < standingCapsuleheight) {
    2.     if (Physics.Raycast(myTransform.position, -myTransform.up, out rayHit, rayCastHeight, clipMask.value) &&
    3.         (rayHit.collider.GetComponent<Rigidbody>() != null)) {
    4.         capsule.height = Mathf.Min(capsule.height + 4 * Time.deltaTime, standingCapsuleheight);
    5.     } else {
    6.         capsule.height = standingCapsuleheight;
    7.     }
    8. }
    It checks if you're standing up while on a rigidbody. If so, you'll stand up more slowly to reduce the upward force from the rigidbody.
     
  7. TechSinsN

    TechSinsN

    Joined:
    Apr 12, 2014
    Posts:
    121
    Ok thanks ive fixed it now , but i have another problem when i drop the weapon it falls through the floor? ive compared it to the MP5 and everything is the same
     
  8. Takahama

    Takahama

    Joined:
    Feb 18, 2014
    Posts:
    169
    Adding 8 more lines in script will effects performance like %0.01
    :/
     
  9. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Make sure the layers are the same.

    You compelled me to test. :) I couldn't find a statistical difference of even 0.0001%. I didn't go to the effort of decompiling the assembly, but it would appear that they compile down to the same thing. Except when standing from a crouch on a physics object, of course; that's handled differently.
     
  10. TechSinsN

    TechSinsN

    Joined:
    Apr 12, 2014
    Posts:
    121
    Ive checked , the layers are the same but its still falling through
     
  11. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Make sure the Weapon Drop Obj prefab (e.g., Pickup_AK47) has these settings:
    • Tag: Usable
    • Layer: Ragdolls/Pickups
    • Box Collider (Is Trigger should NOT be ticked)
    • Rigidbody (Use Gravity should be ticket)
    • Weapon Pickup script
    Remember that this prefab is separate from the weapon GameObject that's a child of !!!FPS Weapons.
     
  12. TechSinsN

    TechSinsN

    Joined:
    Apr 12, 2014
    Posts:
    121
    Just tried what you said and im still having a problem
     
  13. TechSinsN

    TechSinsN

    Joined:
    Apr 12, 2014
    Posts:
    121
    I fixed it , thanks for posting what i need to check , i looked over and realised the layer was set to something different , thanks for your help
     
  14. Takahama

    Takahama

    Joined:
    Feb 18, 2014
    Posts:
    169
    Thanks for fix ^^
     
  15. TechSinsN

    TechSinsN

    Joined:
    Apr 12, 2014
    Posts:
    121
    Ok so , i see xbox controls are already set up which is great but i have added my own torch to the player and i have tried adding it to the inputs but it does not work , i tried using the back button which is joystick button 6
     
  16. unicat

    unicat

    Joined:
    Apr 8, 2012
    Posts:
    425
    Getting this error after picking up a weapon:

    NullReferenceException: GetRef
    WeaponBehavior.Start () (at Assets/!RFPSP/Scripts/Weapons/WeaponBehavior.cs:284)

    What could this be ?

    Another problem is:
    I`m using U5 with Behaviour Designer and the robotnpc can damage my player.
    But my player can not damage the robotnpc.
     
  17. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    578
    you have to open rfps in unity 4.6 and upgrade project with unity 5, untill next update
     
  18. unicat

    unicat

    Joined:
    Apr 8, 2012
    Posts:
    425
    Ok, thank you but i don`t install version 4 anymore. Will wait for an update then.
     
  19. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
  20. unicat

    unicat

    Joined:
    Apr 8, 2012
    Posts:
    425
    Great Help, will look at this. Thank you.
     
  21. OneShotGG

    OneShotGG

    Joined:
    Nov 16, 2012
    Posts:
    225
    Hey there RFPSinites, Im happy to announce that the Bloody Mess beta should be submitted by this Friday. Also, here is a sneak peak at the VPADS framework that will be coming to Bloody Mess during the beta period.

     
  22. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    I'm struggling a little to correctly implement my player model with mecanim and blendtree.
    I'm not sure on how to get the direction of the player for the blendtree.

    I've managed to make my player crouch and jump correctly (though I still need to adjust the camera positions).
    His walk/run state is semi functional also. I am using the speed variable in the FPSRigidBodyWalker script. I had to modify that variable to make sure the speed is set to 0, when the player is not moving. (By default it's at 4..)

    Anyhow, where I'm stuck, is when the character is moving forwards in a 45 degree angle), I want the animation to blend correctly. But I'm not sure on how to retrieve the movement direction of the character?

    I was really hoping to get this resolve with the update of RFPS, I have contacted Azuline 2 weeks ago and never got an answer. :(
     
  23. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    @sluice - What about getting the input axes yourself? Input.GetAxis("Vertical") for forward/back, Input.GetAxis("Horizontal") for left/right. Then you can blend on those axes and speed from the FPSRigidBodyWalker.
     
  24. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    @TonyLi, yeah I remember trying that but had run into some issue.
    It's my first time playing with blendtree, so I guess I'm just a little bit lost in there! lol
    (Ah single player is so much more easier! No networking, no character models and animations :rolleyes:)

    I haven't though of blending the axes with the speed, makes sens.. I will give it a shot tonight. Thanks Tony!
     
  25. OneShotGG

    OneShotGG

    Joined:
    Nov 16, 2012
    Posts:
    225
    I've done quite a bit of work on mecanim blend trees, are you just trying to forward, backward, strafe right and strafe left? Does your character use root motion?

    If so just do something like this (there are likely some errors here)

    Code (CSharp):
    1. public float speed = 1.0f;
    2. private float h = 0.0f;
    3. private float v = 0.0f;
    4. private Animator anim;
    5.  
    6. void Awake () {
    7. anim = gameObject.GetComponent<Animator>();
    8.  
    9. }
    10.  
    11.  
    12. void update () {
    13. h = Input.GetAxis("Horizontal");
    14. v = Input.GetAxis ("Vertical");
    15.  
    16. ///use this if you are not using a controller
    17. if(Input.GetButton("run")) {
    18.      speed = 6.0f;
    19. } else {
    20.    speed = 1.0f;
    21. }
    22.  
    23. anim.SetFloat("Hor", h * speed);
    24. anim.SetFloat("Ver", v * speed);
    25.  
    26. }
    Hor and Ver would be your float variables in the animator. Create a 4 way blend tree using Hor for the x and Ver for the y positions. Set your walks to 1 and your runs to 6 in the animator inspector.

    if not you can do something similar but you need to do the transform movement logic as well (see the third person C# example)
     
  26. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    @OneShotGG,

    Thanks! I'll check this out. Yes, Essentially I just want to do forward, backward, strafe right and strafe left.
    The player will also be able to move while crouching/sneaking, so I'm thinking I will do a 2nd blend tree for that.
    I am not using Root Motion though.

    My current solution is similar to what you propose and the walking/running state works fine. :)
    But I am struggling when the character was strafing and strafing forward.

    By the way, your last demo makes me want to go play Fallout3 again! hee hee.
    Can't wait to try your asset out. I have no use for it at the moment, but just playing with it in the editor will be pure fun!
     
  27. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    I posted some screenshots of a blend tree here that's worked well for me in the past. You can use it with or without root motion. I used an additive layer to add crouching/sneaking on top of this layer.
     
  28. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    @TonyLi, when you mean an additive layer, do you mean using IK (like Final IK) on top of the base animation?
     
  29. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Hi @sluice - No IK. It's just another layer. Its Blending mode is set to Additive. Normally it plays an empty state. But when the character crouches, it plays a crouch animation (clamped). This get applied additively, so if the player is running it looks like a running crouch.

    Additive animation compares the first frame of the animation clip to the current frame, so you need at least two frames: standing in the first frame, crouching in the second. I use a Mixamo "standing to crouch" animation, where the first frame is standing.
     
  30. TechSinsN

    TechSinsN

    Joined:
    Apr 12, 2014
    Posts:
    121
    Im having some trouble with adding a Holosite , i have watched a tutorial but this keeps happening
     

    Attached Files:

  31. QuadMan

    QuadMan

    Joined:
    Apr 9, 2014
    Posts:
    122
    You need to add layer 'Gun' on holosight.
     
  32. NeuroToxin-Studios

    NeuroToxin-Studios

    Joined:
    Dec 7, 2014
    Posts:
    68
    Could anyone please tell me how to make RFPS work with the Realistic Car Controller asset.
    There are tutorials for making UFPS work with it but not RFPS :/
     
  33. TechSinsN

    TechSinsN

    Joined:
    Apr 12, 2014
    Posts:
    121
    Thanks it works now :)
     
  34. QuadMan

    QuadMan

    Joined:
    Apr 9, 2014
    Posts:
    122
    Ahhh Waiting for 1.22 update.....
     
  35. NeuroToxin-Studios

    NeuroToxin-Studios

    Joined:
    Dec 7, 2014
    Posts:
    68
    Same, To be honest now I have kind of lost hope of it ever coming :/
     
  36. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    x3

    x2
     
    thenamesace likes this.
  37. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    An update would be nice, but I don't think it's really necessary. RFPS strikes me as a finished product. With a little upfront setup, it works fine in Unity 5. For better AI (including factions), Opsive has an RFPS package for their excellent Behavior Designer. I don't think anything's missing to create a complete game, other than a save system. And none of the shooter frameworks have any plans to introduce integrated saving. There are plenty of save system plugins on the Asset Store, though.
     
    QuadMan, thenamesace and ZJP like this.
  38. NeuroToxin-Studios

    NeuroToxin-Studios

    Joined:
    Dec 7, 2014
    Posts:
    68
    While I do agree I feel there are some features that need to be added to make this the perfect shooter package, the main one is a full body.
     
  39. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    and throwing grenade?!
     
  40. NeuroToxin-Studios

    NeuroToxin-Studios

    Joined:
    Dec 7, 2014
    Posts:
    68
    If you go back a few pages TonyLi made a demo asset for grenades
     
  41. thenamesace

    thenamesace

    Joined:
    Jan 25, 2014
    Posts:
    157
    I agree it is almost complete ...but i think the dev would not agree as anything i make is never complete ! ...there is always room for tweaking from the dev and i would like to think @TonyLi would agree as he is always tweaking and updating his Dialogue System which may i add is awesome! as far as RFPS goes i would like to see continued support for it as its a great asset and if support dropped off from the dev then sales will too (even with this great community) and hey as we all know devs have to eat! ....fingers crossed for the next update not because we need it but because the asset deserves it!
     
  42. NeuroToxin-Studios

    NeuroToxin-Studios

    Joined:
    Dec 7, 2014
    Posts:
    68
    Well said!
     
  43. RealAspireGames

    RealAspireGames

    Joined:
    Dec 24, 2013
    Posts:
    265
    Hey Everyone!
    I am using Behavior designer for the AI in RFPS. I have installed the 3rd party package that Behavior designer has for the RFPS asset. I am wondering how to set it up so the AI can fight each other example like the soldiers shoot at the robots or zombies, etc.
    Any help would be greatly appreciated. Thank you
     
  44. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Hi @godofwarfare115 - Here's a simple example (<--package) of a soldier shooting at a robot. I added two really short actions: Set Target and Is Target Alive.
    • Set Target just sets the AI's target, which normally defaults to the player.
    • Is Target Alive makes sure that the reference to the target isn't null. Otherwise Can See Target and Attack Player will throw null reference exceptions as soon as the soldier kills the robot.


    If you don't want to do the whole Attack Player action, you can set the target and then use BD's Shoot action instead to fire a single shot.
     
    RealAspireGames likes this.
  45. JACKO4590

    JACKO4590

    Joined:
    Nov 25, 2014
    Posts:
    81
    Hey guys, was wondering if this using a Character Controller or something like it as iv just noticed that the player can not walk up steps. i have just spent the last 2 hours adding planes without mesh renderer on and using that to get up steps but its everything, as i have spent all day building a town i dont want to have to go thought it all and change it.

    What if i add a Character Controller my self to the player? would that mess too much up?
     
  46. NeuroToxin-Studios

    NeuroToxin-Studios

    Joined:
    Dec 7, 2014
    Posts:
    68
    Hello JACKO,

    What you need to do is make a new physics material with zero friction and apply it to the player, this is something that broke in unity 5 for some reason but applying a zero friction material will fix it, if you go back to page 27 I think someone posted a picture of the physics material to put on the player
     
    Last edited: Apr 3, 2015
  47. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    I compiled all the Unity 5 steps for RFPS in a blog post here.
     
  48. JACKO4590

    JACKO4590

    Joined:
    Nov 25, 2014
    Posts:
    81
    Ok thank you for that, that has helped 90% of my problem. The other problem is can i change the step height at all? something like another 0.5 more or something as the top of the stairs is a little bit too high

    Thanks
     
  49. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    I haven't dug into it too deeply, but it looks like you'll have to modify FPSRigidBodyWalker.cs around line 538 to help the rigidbody pop up over stairs that are too high to handle normally. Or you can put an invisible slope collider on the stairs, which will give you nicer camera movement going up and down anyways.
     
    JACKO4590 likes this.
  50. John-Lisenby

    John-Lisenby

    Joined:
    Nov 8, 2013
    Posts:
    122
    Hi Everyone,

    I want to add ammo amount to a weapon type via code, and not by picking up ammo type obj. How can I do this?

    Thanks,

    John