Search Unity

Realistic FPS Prefab [RELEASED]

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

  1. JC_LEON

    JC_LEON

    Joined:
    May 20, 2014
    Posts:
    520
    changed capital letter but error is the same

    Assets/RFPSP/Scripts/HUD/HungerText.cs(20,16): error CS0246: The type or namespace name `EnergyBar' could not be found. Are you missing a using directive or an assembly reference?


    what i miss in this script??
    Code (CSharp):
    1. //HealthText.cs by Azuline Studios© All Rights Reserved
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class HungerText : MonoBehaviour {
    6.     //draw hunger amount on screen
    7.     [HideInInspector]
    8.     public float hungerGui;
    9.     private float oldHungerGui = -512;
    10.     [Tooltip("Color of GUIText.")]
    11.     public Color textColor;
    12.     [Tooltip("Offset from total screen width to position GUIText.")]
    13.     public float horizontalOffset = 0.0425f;
    14.     [Tooltip("Offset from total screen height to position GUIText.")]
    15.     public float verticalOffset = 0.075f;
    16.     [Tooltip("Scaled GUIText size, relative to screen size.")]
    17.     public float fontScale = 0.032f;
    18.     private GUIText guiTextComponent;
    19.     private float oldWidth;//to track screen size change
    20.     public EnergyBar hungerBar; //<-- ADD THIS LINE.
    21.  
    22.     void Start(){
    23.         var energyBarGO = GameObject.Find("Hungerbar"); //<--ADD THIS.
    24.         if (energyBarGO != null) energyBar = energyBarGO.GetComponent<EnergyBar>();//<--ADD THIS.
    25.         guiTextComponent = GetComponent<GUIText>();
    26.         guiTextComponent.material.color = textColor;
    27.         guiTextComponent.fontSize = Mathf.RoundToInt(Screen.height * fontScale);
    28.         oldHungerGui = -512;
    29.         oldWidth = Screen.width;
    30.     }
    31.  
    32.     void Update (){
    33.         if (energyBar != null) energyBar.valueCurrent = (int)hungerGui; //<--ADD THIS.
    34.         //only update GUIText if value to be displayed has changed
    35.         if(hungerGui != oldHungerGui || oldWidth != Screen.width){
    36.             guiTextComponent.text = "Hunger : "+ hungerGui.ToString();
    37.             guiTextComponent.pixelOffset = new Vector2 (Screen.width * horizontalOffset, Screen.height * verticalOffset);
    38.             guiTextComponent.fontSize = Mathf.RoundToInt(Screen.height * fontScale);
    39.             oldWidth = Screen.width;
    40.             oldHungerGui = hungerGui;
    41.         }
    42.     }
    43.  
    44. }
     
    Last edited: Jul 19, 2016
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Sorry, I don't know. In HungerText.cs, the compiler is saying that the script EnergyBar doesn't exist:
    Code (csharp):
    1. public EnergyBar hungerBar; //<-- ADD THIS LINE.
    But if you used these instructions then EnergyBar does exist for HealthText.cs:
    Code (csharp):
    1. public EnergyBar energyBar; //<-- ADD THIS LINE.
    Do you have a typo in HungerText.cs? Is this in the same project as your modified HealthText.cs?
     
  3. JC_LEON

    JC_LEON

    Joined:
    May 20, 2014
    Posts:
    520
    i accomplished and managed to work ..manythaks tonyLi
    hostare immagini

    is there a way we can add stamina and relative bar to fpsplayer??anyone tried before??
     
  4. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    It would require more coding and modifying FPSRigidBodyWalker.cs. Sprinting stamina uses these variables:

    Code (csharp):
    1. public bool sprintActive;//true when sprint button is ready
    2. private float staminaForSprintAmt;//actual duration amt allowed for sprinting modified by scripts
    I don't know what you mean by relative bar.
     
  5. goldencruz

    goldencruz

    Joined:
    Oct 2, 2013
    Posts:
    94
    is anyone else arms huge in the editor but normal in game mode. another question is if i wanted to to make just melee and bows could I take out the guns and does the doc cover how to import new weapons.
     
  6. TryHarder

    TryHarder

    Joined:
    Jan 1, 2013
    Posts:
    121
    Hello,

    I hope someone can help, I'm sure I'm being stupid but I have lets say a maze and some AI in it when they detect me they chase but as soon as I turn a corner they stop and throw this error:-

    NullReferenceException: Object reference not set to an instance of an object
    AI+<AttackTarget>c__Iterator1D.MoveNext () (at Assets/RFPSP/Scripts/AI/AI.cs:878)

    And that line is:-

    float distance = Vector3.Distance(myTransform.position, target.position);

    Has anyone else expericenced this ?

    Any help gratefully recieved thank you.
     
  7. NeuroToxin-Studios

    NeuroToxin-Studios

    Joined:
    Dec 7, 2014
    Posts:
    68
    Yes this is due to the fact that the weapons are rendered on a separate camera.

    Yes you can go into the weapon child of the Player prefab and remove the guns from the weapon array, and then delete the weapon objects (just deleting the objects will throw missing reference errors).

    I do believe that adding weapons is included in the documentation and there are also multiple tutorials on YouTube that will show you how.

    I was in two minds as to whether to respond to this as I am not 100% sure of the issue and didn't want to give you a bad solution but I thought that I might be able to help.
    This error looks like it could be to do with waypoints, are the AI setup to patrol using waypoints or are they set to stand still? if they are set to patrol and have no waypoints then when they lose sight of the player they will try to patrol and find no waypoints hence the error.
    If I am fatally off the mark then I do apologise
     
  8. goldencruz

    goldencruz

    Joined:
    Oct 2, 2013
    Posts:
    94
    Thank you I will look into this
     
  9. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    I just had a chance to look this up. In RFPSP 1.23, the parameters to adjust the camera and capsule collider are on FPS Rigid Body Walker. It's the bottom section, Camera and Capsule Collider. I recommend adjusting these first.

    Then you need to adjust the VisibleBody's Model Stand Scale and Model Crouch Scale to match the new camera position.

    In RFPSP 1.23, the hard-coded values (0.45f) are in FPSRigidBodyWalker.cs lines 660-661. Try adjusting them.

    Have you tried to configure your AI component like the soldier in the sandbox demo scene?

    Have you modified the AI script? This shouldn't happen because there's a null check on line 842, so it's very curious.

    Can you post the inspector view of the AI component?
     
  10. TryHarder

    TryHarder

    Joined:
    Jan 1, 2013
    Posts:
    121
    Thank you Shadow Warrior but no I've trid with and without Waypoints.

    TonyLi, thank you, I've tried using the soldier and Zombie from the demo they both do the same, its really weird, you've put me on to something with the Null check I'm going to really check it all line by line to see who its not getting trapped I'll report back............Cup of tea made...right I'm on it.

    Thank you.

    P.S. AI.cs is unchanged.
     
  11. TryHarder

    TryHarder

    Joined:
    Jan 1, 2013
    Posts:
    121
    Figured it out !!

    Ok I guess I may have told a lie, my target platform is Windows Store Universal 10 when I imported RFPS I do now remember AI.cs not compliling because:-

    // no target - stop hunting
    if(target == null || (TargetAIComponent && !TargetAIComponent.enabled) && !huntPlayer){
    timeout = 0.0f;
    heardPlayer = false;
    heardTarget = false;
    damaged = false;
    TargetAIComponent = null;
    return false;
    }

    "return false;" isnt allowed so I changed this to "yield return false;" this was causing the problem I have now changed line 842 onwards to :-

    // no target - stop hunting
    if(target == null || (TargetAIComponent && !TargetAIComponent.enabled) && !huntPlayer){
    timeout = 0.0f;
    heardPlayer = false;
    heardTarget = false;
    damaged = false;
    TargetAIComponent = null;
    yield break;
    }

    yeild break appears to have fixed my problems, now the AI go pack to patrol once they lose the target.

    Thank you !! And thank you TonyLi you made me focus on that NULL check !!
     
  12. TryHarder

    TryHarder

    Joined:
    Jan 1, 2013
    Posts:
    121
    Here is an easier one to answer I hope,

    Ok so I have a stair case when I get to it the player stops, then I have to jump then i can walk up the stairs. What is the setting to increase the 'step' distance, slope limit doesnt seem to have any effect ?

    Thank you !!
     
  13. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Glad you got that null error thing fixed! Stepping up is controlled by the hard-coded values (0.45f) in FPSRigidBodyWalker.cs lines 660-661. Play around with those lines.
     
  14. Dionysos1111

    Dionysos1111

    Joined:
    Feb 14, 2016
    Posts:
    39
    Hi,

    Can anyone help me? i got this house and i want the zombies to be able to attack and destroy it.
     
  15. JC_LEON

    JC_LEON

    Joined:
    May 20, 2014
    Posts:
    520
    I was wondering if is there a way items can be pickuped but not imediately used like medpack or water bottles or apples so i can make a simple inventory system and use them when i need them...
     
  16. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    You could configure the house as a breakable object. Examine the Glass objects in the sandbox scene for an example. It needs:
    • Tag: something like Wood
    • Layer: Default
    • Collider such as a Box Collider
    • Particle emitter (see the Glass for an example)
    • Breakable Object script.

    It's rather complicated. If you happen to have the Dialogue System and S-Inventory, the Dialogue System has a free integration for RFPS + S-Inventory that handles inventory, vendors, crafting, and saved games. Otherwise you'll have to write an inventory system, a pickup trigger script that adds items to the inventory system, and a UI that pauses the RFPS player and frees up the cursor and/or gamepad so you can navigate the inventory menu.
     
  17. TryHarder

    TryHarder

    Joined:
    Jan 1, 2013
    Posts:
    121
    Hello TonyLi,

    Thank you for the pointer but I can't seem to make it make a difference if I lower the number I cant move at all and I've steadily increased the values from 0.45f to 5f and still no joy and my first step is not that tall at all. Hmmmmm.......
     
  18. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    I'll play around with it this weekend and post back here. I think you need to add an offset to the value to make it higher. It's been a while since I really looked at it.
     
  19. Necrovis

    Necrovis

    Joined:
    Mar 4, 2015
    Posts:
    4
    So my version of RFPSP appears to be stuck on 1.22. There is no option to update the package either. Help?
     
  20. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Are you using Unity 5.2.0 or higher?
     
  21. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    It looks like playing around with the offsets will only get you so far and then it's too tall for the capsule. Can you put a little invisible ramp on the stairs to make each step in effect shorter?
     
    Necrovis likes this.
  22. Necrovis

    Necrovis

    Joined:
    Mar 4, 2015
    Posts:
    4
    Yes. I am currently using version 5.3.6 actually
     
  23. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Try contacting @Azuline Studios with your Asset Store invoice number. Maybe they can help.
     
  24. Necrovis

    Necrovis

    Joined:
    Mar 4, 2015
    Posts:
    4
    Alright thanks bud
     
  25. JC_LEON

    JC_LEON

    Joined:
    May 20, 2014
    Posts:
    520
    has someone tried to change the default arms/hands...

    my game character is not a military so i would to know if there is a possiiblity to change arma
     
  26. Mario167100

    Mario167100

    Joined:
    Jul 25, 2016
    Posts:
    49
    I have a problem. You see, I want to add my own weapons to the FPS Main prefab. The Gun models that I'm using are the default FPScreator guns. I followed all the steps and everything so that I can add my weapon and it actually worked! The actual problem comes in when I switch the layer to "gun", when I do that the entire weapon is gone and I can only see a tiny bit of the stock. I switched it back to default and the weapon appeared as normal (Except it was going into the terrain) Can anybody help me with this? If you need a picture i'll send one.
     
  27. Necrovis

    Necrovis

    Joined:
    Mar 4, 2015
    Posts:
    4
    I had that same issue. I'm sure someone will have another way to help you if you want to keep using the FPS character with two cameras. However, you can avoid this problem by using the player with a single camera.
     
  28. JC_LEON

    JC_LEON

    Joined:
    May 20, 2014
    Posts:
    520
    no one knows an easy way to reskin the arms/hands of the player or to change them??
     
  29. yummybrainz

    yummybrainz

    Joined:
    Jan 14, 2014
    Posts:
    69
    Has anyone else been building for mobile with RFPS recently? I made a few games with it last year and the performance was great!

    Now with the latest releases it's completely useless... :( Frame rates of about 15-20 on an iPhone 6+ when the old version was about 40fps. This is also in a completely empty scene so it's just the character controller. I tried disabling the body view and still no go.

    Anyone else have any luck on mobile?
     
  30. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    @JC_LEON - Sorry, I haven't. If you want to keep the same weapons, maybe it's easiest to simply change the textures.

    @yummybrainz - Have you tried disabling all the extra image effects on the camera? Version 1.22 added a lot of effects such as Motion Blur, etc. Also make sure nothing's being logged to the console, as that will really kill fps.
     
  31. JC_LEON

    JC_LEON

    Joined:
    May 20, 2014
    Posts:
    520
  32. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    578
    Your gonna need to re-animate the arms manually... or you could try Animation Baker from the Asset Store its £FREE, but unsure whether it would work or not.
     
  33. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    If you drill down into FPS Main > FPS Weapons > ... > Shotgun for example, activate the Shotgun GameObject. The child "Shotgun_Anim" is an animated model of arms and shotgun together. If you can get your replacement arms to exactly match the GameObject hierarchy of Shotgun_Anim, you can reuse those animations. Otherwise you'll have to create animations and name them exactly as in Shotgun_Anim (Fire, Reload, Ready, etc.). Unfortunately I don't think Animation Baker will help because the animations aren't Mecanim.
     
  34. zelgo

    zelgo

    Joined:
    Jun 26, 2016
    Posts:
    39
    is there any guide for changing the character model? or is it the same problem as the arms?
     
  35. witcher101

    witcher101

    Joined:
    Sep 9, 2015
    Posts:
    516
    Any1 knows how to create a flame thrower weapon. pool manager seems to need rigidbody and collider so i cant change pool manager
     
  36. NeuroToxin-Studios

    NeuroToxin-Studios

    Joined:
    Dec 7, 2014
    Posts:
    68
    Maybe create a weapon with a Flame Thrower model, sound effects and animations, then drastically reduce the range and fire rate, finally create a fire particle system and then spawn it at the muzzle of the flame thrower when the fire button is held down, then you can adjust the damage until you feel it is realistic
     
  37. witcher101

    witcher101

    Joined:
    Sep 9, 2015
    Posts:
    516
    Tried this ran in to problem were praticles seems to travel too far since your hands are so huge and so far away. Tweaking scale didnt gave disered results either
     
  38. laserway

    laserway

    Joined:
    Aug 1, 2016
    Posts:
    1
    Is it possible to create a game like Doom 1 & 2, Duke Nukem 3D etc. with this asset? Basically a "retro-fps" where enemies are animated 2d sprites in a 3d environment?
     
  39. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Sure. It won't necessarily be any easier than 3D, since you still need to keep track of which direction the enemy is facing relative to the player and play the correct animation (e.g., facing forward, back, left, or right). But if that's the art style you want, it's certainly possible.
     
  40. witcher101

    witcher101

    Joined:
    Sep 9, 2015
    Posts:
    516
    Anyway to fix huge hands problem. I am trying to create flame thrower and fire particles doesnt seems to be visible if enemies are too close to me
     
  41. TryHarder

    TryHarder

    Joined:
    Jan 1, 2013
    Posts:
    121
    Hello,

    I have a strange problem but I'm guessing i've changed something somewhere but I dont know where.

    I'm using keyboard and mouse...

    Any weapon Melee or bullets fires once and only once, so gun 100 ammo fires once then nothing, melee weapon swings once then nothing, pick up any weapon and same thing fires once then thats it!

    Has anyone had this, what have I changed ?? I cant find it !!

    Thank you .
     
  42. TryHarder

    TryHarder

    Joined:
    Jan 1, 2013
    Posts:
    121

    FIXED !!!!

    Battery flat in my mouse !! OMG I need to take a break !

    oh well I guess this will make someone laugh !!
     
    llJIMBOBll likes this.
  43. JC_LEON

    JC_LEON

    Joined:
    May 20, 2014
    Posts:
    520
    Hi 'I'm tryng to add coldness gameplay script based on the hunger script, so player coldness grow over time and can be get down when player make specified action

    so i copied all hunger parts in fpslayer.cs script and duplicate them and renamed the "Hunger" and "hunger" text with "coldness" and "Coldness"

    after that i duplicated the HungerText .cs script and Renamed it to ColdnessText.cs and applied the modifications to the my new ColdnessText Script.. but I have a bunch of error in my console..

    if this the right way to add a new hunger/thirst like variable??
     
  44. TauseefCVS

    TauseefCVS

    Joined:
    Mar 28, 2016
    Posts:
    15
    Hello Everyone !
    i am very confused about characterDamge.cs script , i want to use head and body shot but not yet successful , if anyone have idea about that please share with me and also have any tutorial please send me the link
    Thanks
     
  45. reggie_sgs

    reggie_sgs

    Joined:
    Jun 29, 2014
    Posts:
    276
    Just saw this as a featured asset and tried out the web demo but the camera just spins making it unplayable.
     
  46. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Do you perhaps have a gamepad that's connected and the stick is pressed to one side? I'm not the developer, but I've never come across what you described. Maybe try a different browser. I just ran the demo in IE, and it worked fine.
     
  47. Takahama

    Takahama

    Joined:
    Feb 18, 2014
    Posts:
    169
    THIS IS IMPORTANT!
    @Azuline Studios
    This kid just SELL your asset like it is his own work!
     
    EvilGremlin, thenamesace and Bagnol like this.
  48. SuperNewbee

    SuperNewbee

    Joined:
    Jun 2, 2012
    Posts:
    196
    Has anybody been able to replace hand and gun animations in the latest version? It was easy to do in version 1.22 but now I am completely stumped when trying to do the same thing in version 1.23.I am trying to use animated arms and weapons from BÜMSTRÜMs FPS Weapons asset (https://www.assetstore.unity3d.com/en/#!/content/46108)

    After replacing the arm and weapon it seems to flip upside down and vibrate like crazy as soon as I hit "play".

    Has anyone else run into this problem with latest version RFPS 1.23?
     
  49. QuadMan

    QuadMan

    Joined:
    Apr 9, 2014
    Posts:
    122
    It's same as old version...
     
  50. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    628
    Sorry if this has been answered before (61 pages is a lot to trawl through), but is it possible to add an fps body and legs, so not just the arms? I want to create a Firewatch type fps game...

    Thanks in advance!

    Greg