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

    nixter

    Joined:
    Mar 17, 2012
    Posts:
    320
    Tony, great job getting Bolt working with RFPS! Any chance you could host it with a webplayer build so we could try it out?
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Nope, sorry, I didn't implement a lobby or any way to join. I just wanted to see if I could get the RFPS part working. Maybe someone else could implement the non-RFPS-specific stuff to get a full demo working.
     
  3. zugsoft

    zugsoft

    Joined:
    Apr 23, 2014
    Posts:
    453
    My Multiplayer Game is ready with RFPS and my Java server(hosted on a OVH dedicated server)
    Very happy with the result.
    I just need to send some informations, and finish the Chat.

    I can play with 8 players, but I have only 3 phones, Lumia520 WP8.1, Ativ-S WP8.1 and ZTE (android 4.4).

     
    Last edited: Feb 1, 2015
    QuadMan, mentolatux and Defcon44 like this.
  4. Dotta4

    Dotta4

    Joined:
    Sep 26, 2013
    Posts:
    8
    Hi Menfou,

    I've been messing around with unity navmesh and can't seem to get it to work after I bake the navmesh in a scene. What should I add to the AI script?

    Thank you.
     
  5. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    I am also losing mouse controls (cannot look with the mouse at all).
    I have followed the steps carefully (3 times) and the same problem keeps occurring.

    What is weird is this:
    -When un-check the script BoltPlayer from my Player Prefab and test I get the mouse controls back.

    This also does the same thing when trying with Play as server and Debug Start. But when I play using these 2 options, the player dies at the beginning and then resuscitate?
     
  6. nixter

    nixter

    Joined:
    Mar 17, 2012
    Posts:
    320
    No problem, I understand. But you were able to get the NPCs to work? That is something I haven't seen anyone do with Bolt yet.
     
  7. zugsoft

    zugsoft

    Joined:
    Apr 23, 2014
    Posts:
    453
    Today I added Legs on the player, to help Defcon ;)
     
    Defcon44 likes this.
  8. zugsoft

    zugsoft

    Joined:
    Apr 23, 2014
    Posts:
    453
    In AI.cs


    To add
    Code (CSharp):
    1.    
    2. NavMeshAgent agent;
    3.  
    4.     void Start () {
    5.         agent = GetComponent< NavMeshAgent >();
    6.     }
    7.  
    Find IEnumeratorAttackPlayer (), and add merge.
    Code (CSharp):
    1.  
    2.    IEnumeratorAttackPlayer (){
    3. while (true) {
    4. if(CanSeeTarget()){
    5. //Targetisdead - stophunting
    6. if(target == null){
    7. agent.destination = target.position;
    8. speedAmt = walkSpeed;
    9. yieldbreak;
    10. }
    11.  
    12. if(pursueTarget){
    13. agent.destination = target.position;
    14. lastVisiblePlayerPosition = FPSWalker.leanObj.transform.position;
    15. }else{
    16. lastVisiblePlayerPosition = target.position;
    17. }
    18.  
     
    Last edited: Feb 1, 2015
  9. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Just add BoltAwareDamageable.cs and BoltAwareDestructible.cs to the NPC. Also, you need to spawn or activate them after the player is in the scene. Otherwise the NPCs will try to find the player in Start(), fail, and hang. I updated the script package with a simple TimedActivate.cs script and a small fix to GlobalCallbacks.cs. In my test scene, I deactivated my NPCs and pickups, and added them to the activation list on a 2-second delay.
     
  10. Dotta4

    Dotta4

    Joined:
    Sep 26, 2013
    Posts:
    8
    Edit: Got all working! Thanks again for all the help!

     
    Last edited: Feb 2, 2015
  11. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    EDIT: Scratch that.. the issue has to be in here: BoltPlayerCallbacks.cs

    the script can't find the Bolt Entity
    Code (csharp):
    1. BoltEntity entity = SpawnPlayer();
     
    Last edited: Feb 1, 2015
  12. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Check the steps again. I just followed them in a fresh project and it all works. I added some clarifications to the Setup Player Prefab section, but the procedure is still them same.

    Some things to check:
    • Did you put the Player prefab in a Resources folder?
    • Did you add the scene to the Build Settings?
    • Did you follow all the basic setup steps for Bolt?
    I'm sorry I can't send you a working project, but I'm not the publisher of Bolt or RFPS so I can't redistribute their files.

    Try to get it working in an empty project with only RFPS and Bolt. Once you have the steps down, you can put it into your own project with all your content.
     
  13. nixter

    nixter

    Joined:
    Mar 17, 2012
    Posts:
    320
    I'm able to get the Bolt Server running. Soldiers and aliens are hovering in T-poses, but the zombies seem to be functioning fine. This is the AI hanging problem you mentioned above. I can fix that.

    What concerns me is the client isn't connecting to the server. I'm using Bolt_Beta_v0424_UNITY4_DEBUG and I have the default BoltDebugScene.unity scene (which doesn't give a server/client selection screen) in the build settings prior to the actual !!FPS Prefab Sandbox.unity scene. Both in-editor preview and Bolt Scenes: Play As Server work well enough to load the level correctly.

    Any ideas what may be the problem? Should I be using a different version of Bolt or a different loading scene with server/client selection options?
     
    Last edited: Feb 2, 2015
  14. BlurTimeTeam

    BlurTimeTeam

    Joined:
    Jan 29, 2014
    Posts:
    20
    In this video learn how change zombie character. Enjoy
     
    Last edited: Feb 2, 2015
    QuadMan, GreenZone and mentolatux like this.
  15. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    Yes, I somehow managed to get it working. I have no clue what I was doing wrong to be honest.
    Being new to Bolt and Realistic FPS doesn't help!

    Thanks you for your time!

    Any clue on how many players this should support? Is 12 players out of the question?
     
  16. nixter

    nixter

    Joined:
    Mar 17, 2012
    Posts:
    320
    Bolt has a default support of 64 connections, but you can change that easily. The number I hear banded about usually is about 100 connections. You can adjust how much delay there is between messages so the less accurate the connection, the more players (and AI) can be supported. You can also make areas of interest that will only update those within it, reducing the bandwidth.

    12 should be very doable but it depends on the hosted server or your internet connection if you are running from home.

    BTW: what loading screen are you using for the client? I can't get mine to connect to the server.
     
    sluice likes this.
  17. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Does the "Debug Start" button work? (It's the button to the right of "Play As Server".) In Build Settings > Player Settings..., did you set the windows to run in background?

    I just used the version of Bolt from the Asset Store. I didn't download any updates from the Bolt site.
     
  18. nixter

    nixter

    Joined:
    Mar 17, 2012
    Posts:
    320
    If you download Bolt from the Bolt website, both debug and release versions are available. Fholm encourages people to use the debug builds until release. Right now the Asset Store has 0.4.2.1 and I'm guessing that is the release version?

    I don't have a "Debug Start" button. I guess because I am using the debug version. I'm going to try reinstalling the release version you are using and see if that works. And yeah, I have Run In Background checked.
     
  19. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Sorry, I just remembered that Debug Start is only available in Unity Pro. If you have Pro, it looks like this (from http://wiki.boltengine.com/wiki/21):


    But you should be able to get the same effect in Unity (free) by following the steps in the wiki tutorial.
     
  20. nixter

    nixter

    Joined:
    Mar 17, 2012
    Posts:
    320
    That's why I'm not seeing it. I'm on Unity Free.

    Below is a screenshot of my build settings and the contents of my BoltDebugScene. Do they look correct?

    As I said, my server starts fine in the editor but the client build just stays in the BoltDebugScene without loading the FPSBoltTest scene.
     

    Attached Files:

  21. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    As far as I can tell. This is my first time using Bolt. I'm by no means an expert. You might need to ask for more qualified help on the Bolt forum. If you go through the regular Bolt tutorial (the polyworld third person shooter project), does it work?
     
  22. mentolatux

    mentolatux

    Joined:
    Nov 2, 2014
    Posts:
    240
    THANK YOU MAN plzz add me on skipe as MENTOLATUX
     
  23. nixter

    nixter

    Joined:
    Mar 17, 2012
    Posts:
    320
    Good news. I got the client working. The trick was to attach the Bolt Init script to the camera in the Debug Loader.

    Bad news is I'm still getting wonky behavior. For example:

    1) When a second player arrives in the game, both players have double GUIs with health and ammo overlapping each other.
    2) After a player dies, they no longer have any health (or a GUI for that matter) and are immortal.
    3) If the server player dies, they return unable to move and slowly slide along the ground.
    4) Sometimes all the guns disappear after one is picked up. But not always.

    Also I have the AI working thanks to the Timed Activate script. However, it seems like the enemies are not Bolt objects are they? Each player sees their own enemies in independent locations. The only thing BoltAwareDamageable.cs does is remove the enemy when it's killed. And it will spawn again if the player respawns.

    So at this point NPCs are not working. Not in multiplayer at least. It may not be too difficult make them work though. Just as we have a Player Object, we can have an Enemy Object. All Client enemies would be slaved to the AI in the Server player's instance. This would up the traffic quite a bit (treating each enemy as a player), especially if patrols are still included. Probably best to use spawn (and despawn) triggers for all enemies so that ones out of sight don't eat up traffic.

    I'm going to spend some time cleaning up many of the errors I'm getting (lots of MissingReferenceException errors, particularly with the WaterZone). If someone hasn't solved the NPC issues later this week, I'll take a swing at it.
     
  24. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Great!

    The BoltPlayer.cs script, starting at line 68, disables the GUIText component that gets spawned for proxies (other players). But I forgot to also disable the second GUIText component that's on their child objects. RFPS uses two GUIText components to produce a shadow effect. If I get a chance, I'll update the code in the future to disable both.

    Yup, I didn't implement anything for this. I figured it would depend on the game. If you have some default behavior that you'd like to share, I'll add it to the scripts. Same goes for any other code that you might have added and are willing to share.

    Make sure every destructible has a unique ID. When a player "destroys" a destructible (either by picking it up or making it explode), the destructible sends a network DestroyEvent with its ID number. All destructibles in the scene check their ID number. If it's the same, they destroy themselves to stay in sync.

    Your suggested approach sounds good. It shouldn't be too much traffic if the server handles the AI and only sends decisions (turn left, fire at X, etc.) to the clients, and occasionally syncs position in case the physics gets a little off.
     
  25. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    I'm curious about how to add a third person body to my character..(It adds to the immersion and is a must for multiplayer).

    To be honest, I'm unsure of where to start, any pointer would be great.

    My first though was to check how UFPS does it (since I also own that asset), and start from there. But searching here on the forum, I've read that mecanim animation are a no-go with RFPS? Is that so? I only want to add character animation to playable character as my project is multiplayer only with no NPC what so ever.

    Anyway, any pointer to get me started would be very much appreciated. ;)
     
  26. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Mecanim is only a no-go with NPCs that use the built-in AI script, since that script uses a very specific set of Legacy animation clips. But for PCs, and for NPCs that you control differently such as with Behavior Designer, you can use Mecanim.

    Third-person bodies for other players to see is easier than third-person for yourself. For yourself, you need to also handle the camera differently, since it will be pulled back from the player's position and must also avoid clipping with objects between the camera and player.

    In any case, you'll need to modify the RFPS scripts slightly. For example, when the player fires, the RFPS WeaponBehaviour script needs to notify your third-person scripts to play a third-person firing animation.
     
  27. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    @TonyLi Thanks a lot for the help, buddy. Greatly appreciate it!

    Ok, so mecanim is a go then! Great.
    I'll start by reading a bit more on Mecanim and I'll watch a few video tutorials on how it's use for first person character.
    Handling character is a new territory for me! Learning stuff is fun!:D

    As a first iteration, I will start by having the third-person for other player, only.

    I suppose UFPS (for those who possess it, can possibly be a good place to learn how it is done...
     
  28. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    @nixter, I'm using BoltInit (as per a Bolt Tutorial).

    Basically, you just create a new scene and attach the script BoltInit on the main camera.
    You just have to make sure that this is the first scene of your build, and it should automatically detect the other scenes in your build.

    It's a great solution for prototyping.
     
  29. zugsoft

    zugsoft

    Joined:
    Apr 23, 2014
    Posts:
    453
  30. nixter

    nixter

    Joined:
    Mar 17, 2012
    Posts:
    320
    @sluice Thanks, I got that figured out at little earlier but I appreciate you following up.

    I fixed the MissingReferenceException errors I was getting. They were caused by all the scripts looking for the playerObj. The multiplayer changes cause the player to spawn after them so they are throwing errors, similar to the AI issue.

    I used the Timed Activate script to shut them off until the player arrives. Here's my list:

    !!!Pickups (50 Objects)
    All Pickups

    Objects (16 Objects)
    Nighttime Simple Water
    Pond
    !Ladder
    Fire Damage (x2)
    Mine (x10)

    (an object named Object gets added by default with one of the Fire Damages, hence 16 Objects instead of 15)
     
  31. BlurTimeTeam

    BlurTimeTeam

    Joined:
    Jan 29, 2014
    Posts:
    20
    Your welcome...
     
  32. QuadMan

    QuadMan

    Joined:
    Apr 9, 2014
    Posts:
    122
    Can you make a tutorial for converting mobile device?
     
  33. mentolatux

    mentolatux

    Joined:
    Nov 2, 2014
    Posts:
    240
    hey Blur Time i need again your help when you have time please look on my video from youtube and tell me where im wrong , i try to change character on my fps kit 2.0 and is not working, i try many times without working here is my video
     
  34. jackcrosa

    jackcrosa

    Joined:
    Oct 16, 2012
    Posts:
    22
    If anyone can help me setup my character ( animations ready) using team viewer , I will give you 20 $ , thanks in advance !
     
  35. Kenrod4u

    Kenrod4u

    Joined:
    Apr 8, 2013
    Posts:
    9
    Hey Guys, In the last two weeks I have been experiencing my Real FPS Prefab Character camera spinning uncontrollably. Is anyone else experiencing this? Does anyone have a fix? Once I run the game, the character is able to move, but spins around the terrain with no input... Please help. Thanks Ken
     
  36. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    @Kenrod4u, I got this issue also when using Bolt with RFPS. The problem happens when the player prefab is already in the scene and launching the game with Play as Server

    If you are not using Bolt, I have no clue as I'm still new to RFPS..

    You don't have any error showing in the console?
    I would start by checking Edit/Project Settings/Inputs, to make sure everything is set as it should.

    Sorry I can't be of more help! :p
     
  37. Kenrod4u

    Kenrod4u

    Joined:
    Apr 8, 2013
    Posts:
    9
    Thanks sluice, unfortunately I am not using Bolt. However, I see you guys are making some headway...

    The Edit/Project Settings/Inputs is a great start!

    Best Regards

    Ken
     
  38. Jack62Lewis

    Jack62Lewis

    Joined:
    Jun 17, 2013
    Posts:
    105
    Hi,
    I've bought an asset store product that requires me to make my unity terrain have a new layer named "Ground". Unfortunately, this makes my RFPS freeze as soon as I walk onto it.
    Anyway to make the player work on this layer?
     
  39. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    @Jack62Lewis, I suppose you have change the layer World Collision used in RFPSto Ground
    or go into your new asset and change that layer Ground to World Collision.
     
  40. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Just wanted to add to what @sluice said. You don't have to change any scripts. Just rename layer #10 to Ground.
     
  41. BlurTimeTeam

    BlurTimeTeam

    Joined:
    Jan 29, 2014
    Posts:
    20
    Hi. I have not Fps kit 2.0
     
  42. mentolatux

    mentolatux

    Joined:
    Nov 2, 2014
    Posts:
    240
    lets talk on private or add me on skipe plzz Blur Time, im stuck on my project with character not working to change
     
  43. Jack62Lewis

    Jack62Lewis

    Joined:
    Jun 17, 2013
    Posts:
    105
    Thanks for the replies.
    I went to the layers section and found that my layer 10 hadn't been named in the first place and changing it to ground hasn't worked.
     
  44. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Does your terrain asset also assume a certain layer number, like RFPS does? Is it something you can change? A lot of assets have configurable LayerMask dropdowns.

    If it goes by name, make sure the case is correct ("Ground" vs. "ground").
     
  45. Jack62Lewis

    Jack62Lewis

    Joined:
    Jun 17, 2013
    Posts:
    105
    I bought something called HerdSim. And the animals in the simulation can only walk on a surface with the Ground layer as far as I can tell. But when I change the terrain from the layer default to Ground, that causes the RPFS player to freeze.

    EDIT: My bad sorry, when I moved the Ground layer to layer 10 i didn't think to update the terrains layer to the new Ground one. It all works fine now thanks.
     
    TonyLi and sluice like this.
  46. sluice

    sluice

    Joined:
    Jan 31, 2014
    Posts:
    416
    @Jack62Lewis, Making a Cow Tipping Simulator, aren't you!? :eek:

    Glad it work! I also got that HerdSim asset yesterday. I might end up using it with RFPS... this will save me a bit of time, if I do.
     
  47. Jack62Lewis

    Jack62Lewis

    Joined:
    Jun 17, 2013
    Posts:
    105
    Haha I got it yesterday too. Had to take advantage of that sale :)

    New question guys, I'm currently trying to add my own enemies in my game that run on RAIN AI, with mecanim animations and also use rag-dolls for when they die. The only thing I would like to retain from the RPFS enemies is the recognition of being shot and the ability to attack the player (This is a zombie so for right now it doesn't need to be shooting the player, just hitting).
    Where shall I start in doing this..?
     
  48. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Looks like we're all going to be adding herds to our games. Hard to resist those sales. :)

    When WeaponBehavior.cs hits a target on the NPCs layer, it looks for a CharacterDamage script. As long as you add this script to your NPC, it should take damage and die. You'll probably want to add a line to CharacterDamage.cs that notifies RAIN, too.

    To make it attack the player, you'll have to remove AI.cs and use RAIN for movement, firing, and animation.
     
  49. Jack62Lewis

    Jack62Lewis

    Joined:
    Jun 17, 2013
    Posts:
    105
    Thanks a lot. This looks like it'll provide a great starting point for me.
    To make it hurt the player and for the player to see this and remove health and do the blood screen overlay thing, where's the script/function for that.
     
  50. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    On the NPC, AI.cs plays the shoot animation and broadcasts the message "Fire" to itself. NPCAttack.cs listens for this message and handles hitting things, including the player. Instead of AI sending "Fire", your RAIN BT can send "Fire" to NPCAttack.