Search Unity

Realistic FPS Prefab [RELEASED]

Discussion in 'Assets and Asset Store' started by Azuline-Studios, Apr 5, 2013.

  1. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    10,018
    @jons190 - If you have a paid version of a Pixel Crushers asset, such as the Save System for RFPSP, delete this folder:

    Assets/Plugins/Pixel Crushers/Common/Scripts

    and make sure the DS eval version imports this file:

    Assets/Plugins/Pixel Crushers/Common/DLLs/PixelCrushers.dll
     
  2. amansweb

    amansweb

    Joined:
    Dec 20, 2017
    Posts:
    3
    trailer for my mobile game. Made using RFPS.

     
    TonyLi likes this.
  3. jons190

    jons190

    Joined:
    Sep 13, 2016
    Posts:
    243

    Yes I do runt he paid version of save system.

    So update: I set my build settings to :
    Android
    and then set the build backend to
    .net 4.0
    and this seemed to do the trick. No pathing errors. but now I get input errors (axis not set up) which I think is on my end, since I am doing lots of funcky stuff with the inputs to get it all to work in VR.

    But I will experiment with these steps and see what transpires....
    I was laying with it last night and think this all has EXACTLY the features I wanted. I wanted to add some sort of "character builder" and think I can achieve a bit of this with the Quest log by showing this screen in my transitional scenes between levels. Then structure my quests like:
    YOu have found three of the four skulls and you attack rating is +10%.
    Youhave found the ring of power + 2 on damage given..
    ect.

    So I may havve some questions the next few days as I try and set this all up. Cheers mate!
     
  4. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    10,018
    Hi @jons190 - This page shows the input axis settings that you need to set up for Unity UI. (The Dialogue System integration assumes that the project is ready for Unity UI.)

    That's a good idea!
     
  5. Bioman75

    Bioman75

    Joined:
    Oct 31, 2014
    Posts:
    15
    Does anyone know of a simple way to give a weapon to the player? I am using the wave survival example to make something similar to cod zombies. I have the points and "mystery box" systems working but wall buying weapons has kinda stumped me. I see there is a function in PlayerWeapons that gives all weapons to everyone, and wanted to know if I could invoke something similar that gives specific weapons that I assign in the inspector.
     
  6. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    10,018
    You need a reference to your PlayerWeapons component. Weapons are identified by their index number in PlayerWeapons' Weapon Order list. To give a weapon, such as weapon 3 (by default the shotgun):
    Code (csharp):
    1. var playerWeapons = FindObjectOfType<PlayerWeapons>();
    2. playerWeapons.weaponOrder[3].GetComponent<WeaponBehavior>().haveWeapon = true;
    To equip the weapon, run PlayerWeapons' SelectWeapon coroutine with the weapon index number:
    Code (csharp):
    1. StartCoroutine(playerWeapons.SelectWeapon(3));
     
    Last edited: Dec 7, 2019
    Bioman75 likes this.
  7. Bioman75

    Bioman75

    Joined:
    Oct 31, 2014
    Posts:
    15
    Thanks but i'm getting this error
    error CS1061: Type `UnityEngine.GameObject' does not contain a definition for `haveWeapon' and no extension method `haveWeapon' of type `UnityEngine.GameObject' could be found. Are you missing an assembly reference?


    This is my wall buy script.
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class WallBuy : MonoBehaviour {
    6.     private FPSPlayer FPSPlayerComponent;
    7.     private WeaponPickup weaponpick;
    8.     private Transform myTransform;
    9.     private int weaponToDrop;
    10.     [Tooltip("Amount of cash that it costs.")]
    11.     public float Price = 500.0f;
    12.     [HideInInspector]
    13.     public WeaponBehavior WeaponBehaviorComponent;
    14.     [HideInInspector]
    15.     public PlayerWeapons PlayerWeaponsComponent;
    16.     [HideInInspector]
    17.     public GameObject weaponObj;
    18.     public int weaponNumber = 0;
    19.     public string WeaponName = "";
    20.    
    21.     //Called on start
    22.     void Start () {
    23.         FPSPlayerComponent = Camera.main.transform.GetComponent<CameraControl>().playerObj.GetComponent<FPSPlayer>();
    24.         PlayerWeaponsComponent = FindObjectOfType<PlayerWeapons>();
    25.     }
    26.  
    27.     //Checks if player is in range of wall buy then prints message
    28.     void OnTriggerStay(Collider other) {
    29.         if (other.gameObject.tag == "Player")
    30.         {
    31.             if (Input.GetButtonDown ("Use")) {
    32.                 FPSPlayerComponent.RemoveCash (Price);
    33.                 PlayerWeaponsComponent.weaponOrder[6].haveWeapon = true;
    34.                 StartCoroutine(PlayerWeaponsComponent.SelectWeapon(6));
    35.                 //weaponpick.PickUpItem ();
    36.                 Debug.Log ("Bought " + WeaponName + "for " + Price);
    37.                 return;
    38.                     }
    39.         }
    40.     }
    41.        
    42. }
     
  8. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    10,018
    @Bioman75 - Sorry, typo. That line should be:
    Code (csharp):
    1. playerWeapons.weaponOrder[3].GetComponent<WeaponBehavior>().haveWeapon = true;
    I fixed it in my post above, too.
     
    Bioman75 likes this.
  9. Bioman75

    Bioman75

    Joined:
    Oct 31, 2014
    Posts:
    15
    Thank you it works flawlessly now :)
     
  10. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    10,018
    Glad I could help!
     
    SickaGamer and Bioman75 like this.
  11. Bioman75

    Bioman75

    Joined:
    Oct 31, 2014
    Posts:
    15
    My max weapon count is 2 but when ever I buy a gun it increases, is it possible to get the currentweapon int in order to replace the currently held weapon?
     
  12. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    10,018
    I'm not quite sure what you mean. If you want to limit the number of weapons the player has, you can set haveWeapon false for some of them. If you want to know what weapon the player currently has equipped, check the PlayerWeapons component's currentWeapon int.
     
  13. Bioman75

    Bioman75

    Joined:
    Oct 31, 2014
    Posts:
    15
    So the wall buy script I showed earlier checks the weapon number of the wall buy and gives you that weapon by setting HaveWeapon to True. The problem is that this disregards the max weapon count and just adds the guns to the players "inventory" instead of replacing them.
     
  14. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    10,018
    You need to check the weapon count yourself in that case. Call PlayerWeapon's UpdateTotalWeapons() method. Then check its totalWeapons variable. See the WeaponPickup script's PickUpItem() method for an example.
     
  15. Bioman75

    Bioman75

    Joined:
    Oct 31, 2014
    Posts:
    15
    Works great kinda, thank you again for the support. ;) I'm not that familiar with rfps so sorry for the questions.
     
    Last edited: Dec 15, 2019
    TonyLi likes this.
  16. A0101A

    A0101A

    Joined:
    Aug 9, 2013
    Posts:
    192

    ... now you can re-texture weapons and player hands to something original, not just using the rfps default textures ... and same - for the sounds, as well ... Guys, we need to let know everyone that it does not make you any popularity for your project using original textures and sounds from RFPS, since the asset has such great potential it's plainly careless to do that way. Also, for the quality sake: at least apply the mid frequencies cut to the all game sounds before you put on you tube any game creations, (annoying sounds in the enhanced mid frequencies - it's the first place that gamers get to hate you, so as the rest of the community, noobs beware, we hope it helps to enhance the overall community standard, as well). It's Unity, it's what we do :). RDA-AlienMoon-Harold.JPG
     
    Last edited: Dec 14, 2019
  17. SickaGamer

    SickaGamer

    Joined:
    Jan 15, 2018
    Posts:
    878
    @TonyLi you should just buy this asset and keep it up!
     
    A0101A likes this.
  18. Bioman75

    Bioman75

    Joined:
    Oct 31, 2014
    Posts:
    15
    For some reason It wont give me an ammo refill when I go to buy the wall buy again after I deplete some rounds. When I check the console it prints the at max ammo message when i'm clearly not.

    Code (CSharp):
    1. //Checks if player is in range of wall buy, gives weapon, removes cash then prints message
    2.     void OnTriggerStay(Collider other) {
    3.         PlayerWeapons PlayerWeaponsComponent = Camera.main.transform.GetComponent<CameraControl>().weaponObj.GetComponent<PlayerWeapons>();
    4.         WeaponBehavior WeaponBehaviorComponent = weaponObj.GetComponent<WeaponBehavior>();
    5.         WeaponBehavior CurrentWeaponBehaviorComponent = PlayerWeaponsComponent.CurrentWeaponBehaviorComponent;
    6.         if (other.gameObject.tag == "Player")
    7.         {
    8.             if (Input.GetButtonDown ("Use")) {
    9.                 if (FPSPlayerComponent.cash >= Price) {
    10.                     if(!WeaponBehaviorComponent.haveWeapon){
    11.                         if(PlayerWeaponsComponent.totalWeapons == PlayerWeaponsComponent.maxWeapons && WeaponBehaviorComponent.addsToTotalWeaps){
    12.                             //determine if this weapon can be dropped (weapons like fists or a sidearm can be set to not be droppable)
    13.                             if (CurrentWeaponBehaviorComponent.droppable) {
    14.                                 //drop current weapon if dropCurrentWeapon is true
    15.                                 if (removeOnUse && !WeaponBehaviorComponent.dropWillDupe && !CurrentWeaponBehaviorComponent.dropWillDupe) {
    16.                                     PlayerWeaponsComponent.DropWeapon (PlayerWeaponsComponent.currentWeapon);  
    17.                                 } else {//replace current weapon if dropCurrentWeapon is false
    18.                                     CurrentWeaponBehaviorComponent.haveWeapon = false;
    19.                                     CurrentWeaponBehaviorComponent.dropWillDupe = false;
    20.                                     //prevent dropping this weapon and creating duplicated ammo by picking up the weapon again from the non-destroyable pickup item
    21.                                     WeaponBehaviorComponent.dropWillDupe = true;
    22.                                 }
    23.  
    24.                             } else {//currently held weapon is not dropable, so find next item in the weaponOrder array that is droppable, and drop it
    25.  
    26.                                 for (int i = PlayerWeaponsComponent.currentWeapon; i < PlayerWeaponsComponent.weaponOrder.Length; i++) {
    27.                                     if (PlayerWeaponsComponent.weaponOrder [i].GetComponent<WeaponBehavior> ().haveWeapon
    28.                                         && PlayerWeaponsComponent.weaponOrder [i].GetComponent<WeaponBehavior> ().droppable) {
    29.                                         weaponToDrop = i;//found the weapon to drop, break loop
    30.                                         break;
    31.                                         //no weapon found to drop counting up from current weapon number in weaponOrder array, so start at zero and count upwards
    32.                                     } else if (i == PlayerWeaponsComponent.weaponOrder.Length - 1) {
    33.                                         for (int n = 0; n < PlayerWeaponsComponent.weaponOrder.Length; n++) {
    34.                                             if (PlayerWeaponsComponent.weaponOrder [n].GetComponent<WeaponBehavior> ().haveWeapon
    35.                                                 && PlayerWeaponsComponent.weaponOrder [n].GetComponent<WeaponBehavior> ().droppable) {
    36.                                                 weaponToDrop = n;
    37.                                                 break;//found the weapon to drop, break loop
    38.                                             }
    39.                                         }
    40.                                     }
    41.                                 }
    42.  
    43.                                 if (removeOnUse && !WeaponBehaviorComponent.dropWillDupe) {//drop the next weapon if dropCurrentWeapon is true and current weapon is not droppable
    44.                                     PlayerWeaponsComponent.DropWeapon (weaponToDrop);  
    45.                                 } else {//replace the next weapon if dropCurrentWeapon is false and current weapon is not droppable
    46.                                     PlayerWeaponsComponent.weaponOrder [weaponToDrop].GetComponent<WeaponBehavior> ().haveWeapon = false;
    47.                                     PlayerWeaponsComponent.weaponOrder [weaponToDrop].GetComponent<WeaponBehavior> ().dropWillDupe = false;
    48.                                     //prevent dropping this weapon and creating duplicated ammo by picking up the weapon again from the non-destroyable pickup item
    49.                                     WeaponBehaviorComponent.dropWillDupe = true;
    50.                                 }
    51.                             }
    52.                         }
    53.                     }else{//the player already has this weapon, so give them ammo instead
    54.  
    55.                         if ((WeaponBehaviorComponent.ammo < WeaponBehaviorComponent.maxAmmo && removeOnUse)//player is not carrying max ammo for this weapon
    56.                             && WeaponBehaviorComponent.meleeSwingDelay == 0) {//player is not trying to pick up a melee weapon they already have
    57.  
    58.                             if(WeaponBehaviorComponent.ammo + WeaponBehaviorComponent.bulletsPerClip > WeaponBehaviorComponent.maxAmmo){
    59.                                 //just give player max ammo if they only are a few bullets away from having max ammo
    60.                                 WeaponBehaviorComponent.ammo = WeaponBehaviorComponent.maxAmmo;
    61.                                 Debug.Log ("Bought ammo for " + WeaponName + " for " + Price);
    62.                             }else{
    63.                                 //give player the bulletsPerClip amount if they already have this weapon
    64.                                 WeaponBehaviorComponent.ammo += WeaponBehaviorComponent.bulletsPerClip;
    65.                                 Debug.Log ("Bought ammo for " + WeaponName + " for " + Price);
    66.                             }
    67.  
    68.                             return;
    69.  
    70.                         }else{
    71.                             //if player has weapon and is at max ammo, just play beep sound
    72.                             //audioData.Play(0);
    73.                             Debug.Log ("At max ammo");
    74.                             return;
    75.                         }  
    76.                     }
    77.                     FPSPlayerComponent.RemoveCash (Price);
    78.                     asource.PlayOneShot(buyFx, 1.0f);
    79.                     PlayerWeaponsComponent.weaponOrder[weaponNumber].GetComponent<WeaponBehavior>().haveWeapon = true;
    80.                     StartCoroutine(PlayerWeaponsComponent.SelectWeapon(weaponNumber));
    81.                     PlayerWeaponsComponent.UpdateTotalWeapons();
    82.                     Debug.Log ("Bought " + WeaponName + " for " + Price);
    83.                     //return;
    84.  
    85.                 } else {
    86.                     //player cant afford wallbuy
    87.                     audioData.Play(0);      
    88.                     Debug.Log ("Doesnt have enough to buy " + WeaponName);
    89.                 }
    90.  
    91.             }
    92.         }
    93.     }
     
  19. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    10,018
    @Bioman75 - Each ammo-based weapon has two counts:
    • ammo: The number of bullets in the player's "inventory"
    • bulletsLeft: The number of bullets in the weapon's magazine
    The code above (from WeaponPickup) will only top up ammo. I recommend tracing through your code with a debugger so you can see where it's going and what the variable values are.
     
    Bioman75 and A0101A like this.
  20. jaberwocky

    jaberwocky

    Joined:
    Nov 28, 2016
    Posts:
    98
    For various reasons I would like to use my own player controller, but would like to keep the AI functionality of RFPSP. However I cannot figure out what I need to add to my player to get a Zombie or a Bad Soldier to chase him. Any tips on what I need as a minumum or how I might modify the AI.cs so that I don't need so much would be greatly appreciated
     
    Last edited: Dec 16, 2019
  21. F0GZ

    F0GZ

    Joined:
    Feb 22, 2018
    Posts:
    33
    TonyLi likes this.
  22. F0GZ

    F0GZ

    Joined:
    Feb 22, 2018
    Posts:
    33
    Ah, and also trailer

     
    A0101A likes this.
  23. amansweb

    amansweb

    Joined:
    Dec 20, 2017
    Posts:
    3
    Yes, Ill be changing the default models, textures and sounds in the next update.
     
    A0101A likes this.
  24. A0101A

    A0101A

    Joined:
    Aug 9, 2013
    Posts:
    192
    We are well, thanks Peter here at the aussie side, RFPS is a community value and from here - further to universities - it's a movement, same as we predicted back in the day it started and we all multiple-puchased it to support the Azuline, with the addition of the high quality forum members right here. ALL THE BEST FOR 2020 - TO ALL RFPS MOVEMENT MEMBERS AND FANS - AND TO ALL RFPS FORUM MEMBERS. HAPPY NEW 2020 YEAR - BY OZTRONIX STUDIOS.jpg
     
    F0GZ likes this.
  25. A0101A

    A0101A

    Joined:
    Aug 9, 2013
    Posts:
    192
    ... nice 2-pipe shot gun, how soon on the steam (the first sequel) ? :).
     
  26. F0GZ

    F0GZ

    Joined:
    Feb 22, 2018
    Posts:
    33
    Its just second game :D
    3 of January is the release date
     
  27. F0GZ

    F0GZ

    Joined:
    Feb 22, 2018
    Posts:
    33
    A0101A, leandrovtd and TonyLi like this.
  28. Takahama

    Takahama

    Joined:
    Feb 18, 2014
    Posts:
    164
    Hello
    i need help about NPC tracer effects. I tried to change "Velocity over lifetime" setting in particle settings but it also affected TPS tracers too.
    NPCs always shot above player's head. When you check "Draw debug gizmo" on AI.cs you can see they directly aim at player's head and most of their shots looks like missing the player due to that.
    How do i change where NPC shoots? it seems like they always target top of the Player capsule collider but i am unable to find its place in the code.


    EDIT: Maybe this is a simpler solution; How do i make NPC tracer and TPS tracer seperate instead of using NPC tracer for both NPC and TPS mode?

    EDIT2: On WeaponEffects.cs i tried to add my own particle "tpsTracerParticles"(Also set an effect in inspector) and changed line 385's npcTracerParticles to tpsTracerParticles but it didn't work on my end..

    Line 50:
    Code (CSharp):
    1.  public ParticleSystem tpsTracerParticles;
    Line 382:
    Code (CSharp):
    1.  if(isPlayer && !WeaponBehaviorComponent.MouseLookComponent.thirdPerson){
    2.             tracerParticles = playerTracerParticles;
    3.         }else{
    4.             tracerParticles = tpsTracerParticles;
    5.         }
    I really need help about this. This is my second time asking help for this issue.
    Thanks.
     

    Attached Files:

    • help.png
      help.png
      File size:
      294.6 KB
      Views:
      18
    Last edited: Jan 15, 2020
  29. A0101A

    A0101A

    Joined:
    Aug 9, 2013
    Posts:
    192

    Looks like you complicated for your self very nicely this far, so our first advice will be: that you (still) keep using same particle source for the FPS, and TPS view, so you will have to deal only with one setting and one particle source for tracers uses in the both views, and it will help you a lot for the start. So, for now - just check that in both cases they all draw from the same particle source, and you use, have (and edit) only one, for the both of views. Further - for every of these 2 separate views - (FPS and TPS) will be: to change (or add) the tracer origin object (transform location) or code edit tracer coordinates where it appears, on its origin object, to get it done. However we are strongly against creating another tracer system completely, and you are definitely in the wrong street from that reason only, at the moment, as it seems. Also: why declare: Else { when third else condition does not exist to be used, the #C can see everything in other scripts, under "public" and absolutely hates when we do stuff like that extra else, it doesn't know what to do with it if the third condition for it does not exist, so no need to use it there, really, just a tip extra, out of curiosity here. Don't Open - RFPS & Doors Package.JPG
     
    Last edited: Jan 20, 2020
  30. Takahama

    Takahama

    Joined:
    Feb 18, 2014
    Posts:
    164
    Code (CSharp):
    1.  
    2.         if(isPlayer && !WeaponBehaviorComponent.MouseLookComponent.thirdPerson){
    3.             tracerParticles = playerTracerParticles;
    4.         }else{
    5.             tracerParticles = npcTracerParticles;
    6.         }
    On code above, if i take npcTracerParticles from there and make "MouseLookComponent.thirdPerson" only use FPS tracers, it also turns NPC tracers into FPS tracers..
    When i search "BulletTracers", both WeaponEffects.cs and NPCattack.cs calls "BulletTracers" component and i have no idea how to change that.

    I just want to change the way NPC tracers travels(they just goes above player's head) without affecting TPS view's tracers.
    And since i am a noob at coding, a step by step guide will be most welcome.
    Thanks :(

    Update: Increasing eye height of the NPC to something like 2.3 makes tracer effects looks okay, but it changes eye height :/
     
    Last edited: Jan 20, 2020
  31. jons190

    jons190

    Joined:
    Sep 13, 2016
    Posts:
    243
    Hey sorry for the late delay. In the end, I let Unity just sit a bit and peculate and majically all the errors went away. I think Unity had some mid-state package installs like the oculus utils and maybe even the RFPS package that had to finish installing. All seemly working just fine now!
     
    TonyLi likes this.
unityunity