Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

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:
    9,682
    @jons190 - You may need to tick Save On Pause and/or Save On Lose Focus. When you close an Android app by hitting the home button, it doesn't actually close. Android just pauses it.
     
  2. jons190

    jons190

    Joined:
    Sep 13, 2016
    Posts:
    223
    Shouldn't the save system save between scene changes? and then pick up that scene on reload? Anyway. i am suspicious I have a corrupt project. Actually not corrupt per say, but I've done a few upgrades through this code base. Unity 5.2 to 5.6 to 2018.16f to 2018.4.6lts and I think three version of RFPS and almost every version of save system I've upgraded the project though. i have a sneaky hutch something got lost in the translations. i loaded up a new project in 2018.lts with all the latest greatest and it's different..... I am still getting everything working at a baseline and will report back in about 48 hours....



     
  3. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    9,682
    When changing scenes, it saves to memory only. You actually have to tell it to save to a slot to make it save to persistent storage such as disk or PlayerPrefs.

    If it's not restoring to the scene that you saved in, make sure the Save System component's Save Current Scene checkbox is ticked.

    Okay, good luck!
     
  4. petercoleman

    petercoleman

    Joined:
    Feb 21, 2016
    Posts:
    196
    Hi everyone,

    I have an issue with terrain texture map and am receiving a non critical console error message and have a read about the error in general but don't know how to correct it in the Footsteps.cs script.

    Texture rectangle is out of bounds (1675 + 1 > 1024)
    UnityEngine.TerrainData:GetAlphamaps(Int32, Int32, Int32, Int32)
    Footsteps:GetTexturesAtPoint(Vector3) (at Assets/RFPSP/Scripts/Player/Footsteps.cs:296)
    Footsteps:GetTerrainTextureIndex(Vector3) (at Assets/RFPSP/Scripts/Player/Footsteps.cs:307)
    Footsteps:FootstepSfx() (at Assets/RFPSP/Scripts/Player/Footsteps.cs:212)

    Not had this appear until recently and have not done anything different as far as I am aware.

    Any help would be appreciated so I can just remove the annoying console error message and don't like them hanging about and compounding or one ends up with endless numbers.

    Thank you kindly.

    I hope you are all well and still developing :)

    Peter
     
    jons190 likes this.
  5. Oderus_Urungus

    Oderus_Urungus

    Joined:
    Jun 8, 2017
    Posts:
    96
    Has anyone found an actual fix for the camera in third person clipping though the environment and player mesh? I'm on 2019.1 and the last update for RFPS and the issue seems to persist.
     
  6. jons190

    jons190

    Joined:
    Sep 13, 2016
    Posts:
    223
    Ahhh taht actuall clears a few things up for me.
    Ahhh that actually clears a few things up for me....

    Anyway. Got it working.
    Built out a new project with all the latest greatest stuff. unity 2018lts, ovr 1.39, rfps 1.4 and the latest save system. Everything seemed to work right out of the box.


    then went back to my project, deleted whatever version I had of the save system, re-imported the newest and then cleaned up all my player settings in each level and got it all to work. There seems to be issues around the saver key. but I haven't put my finger on it exactly yet. I suspect I am doing some funky user scenarios with scean transitions that you might not have thunk of. Tonight I am going to try the "add a few seconds before loading" setting. I think I had issues with that as well before... but as it stands , everything seems to be working like it should.... cheers mate!
     
  7. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    9,682
    @jons190 - Great! Sounds like you're making good progress. Every saver should have a unique key. An easy way to assign unique keys in a scene is to select menu item Tools > Pixel Crushers > Common > Save System > Assign Unique Keys.... If you don't like the random numbers assigned to each saver, you can always change individual keys manually.
     
    jons190 likes this.
  8. sebasfreelance

    sebasfreelance

    Joined:
    Aug 27, 2015
    Posts:
    215
    Sorry my inglish.

    Can someone help me, I don't know if it has been commented before in the forum.

    I am working in the third person, there is some way that when the character is stopped turn when the camera turns, if I start to walk the character is oriented with the camera, but when I stop, I turn the camera and the character keeps looking and does not follow the camera.

    can you help me? I don't know if it brings the option, or you have to touch some code,

    thx!
     
  9. sebasfreelance

    sebasfreelance

    Joined:
    Aug 27, 2015
    Posts:
    215
    I found it! ;)

    thx!
     
  10. sebasfreelance

    sebasfreelance

    Joined:
    Aug 27, 2015
    Posts:
    215
    Hi!

    I am trying to do the following without success.

    when I select a weapon from my inventory
    this weapon is activated and the model is visible
    when it is active, I want to select a specific RFPSP weapon, for example the knife, which is the (1) of the "Weapon Order"

    if it is hidden, select the weapon (0) that is the! Unarmed

    I have another script that I load all the weapons as soon as I start

    void Start ()
    {
    FPSPlayerComponent.PlayerWeaponsComponent.GiveAllWeaponsAndAmmo ();
    }

    can you please help me!

    thx!
     
  11. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    9,682
    @sebasfreelance - To activate a weapon, run the PlayerWeapons component's SelectWeapon(#) coroutine.

    For example:
    Code (csharp):
    1. var playerWeapons = FindObjectOfType<FPSPlayer>().PlayerWeaponsComponent;
    2. StartCoroutine(playerWeapons.SelectWeapon(1)); // Use weapon 1.
     
    llJIMBOBll likes this.
  12. sebasfreelance

    sebasfreelance

    Joined:
    Aug 27, 2015
    Posts:
    215
    Thank you very much for your response! It works very well if I have it in Start, but it fails me in my script, I tell you

    This is the script I am doing for when I have an object of my inventory visible in my hand, select a specific RFPSP weapon, if it is hidden, select the weapon! Unarmed

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class testweapons : MonoBehaviour
    4. {
    5.     public FPSPlayer FPSPlayerComponent;
    6.     public GameObject actWeapon;
    7.  
    8.     void Start()
    9.     {
    10.         //FPSPlayerComponent.PlayerWeaponsComponent.GiveAllWeaponsAndAmmo();
    11.         //var playerWeapons = FindObjectOfType<FPSPlayer>().PlayerWeaponsComponent;
    12.         //StartCoroutine(playerWeapons.SelectWeapon(1)); // Use weapon 1.
    13.     }
    14.  
    15.     // Update is called once per frame
    16.     void Update()
    17.     {
    18.         if (actWeapon.activeInHierarchy == true)
    19.         {
    20.             OnEnable();
    21.         }
    22.         else if (actWeapon.activeInHierarchy == false)
    23.         {
    24.             OnDisable();
    25.         }
    26.     }
    27.  
    28.     void OnEnable()
    29.     {
    30.         var playerWeapons = FindObjectOfType<FPSPlayer>().PlayerWeaponsComponent;
    31.         StartCoroutine(playerWeapons.SelectWeapon(1)); // Use weapon 1.
    32.     }
    33.  
    34.     void OnDisable()
    35.     {
    36.         var playerWeapons = FindObjectOfType<FPSPlayer>().PlayerWeaponsComponent;
    37.         StartCoroutine(playerWeapons.SelectWeapon(0)); // Use weapon 1.
    38.     }
    39. }
    If I delete // and leave only what I have in Start, it works fine, the Player appears with the knife in my hand and there are no failures

    but if I leave the script as I have it, it gives me bugs.

    NullReferenceException: Object reference not set to an instance of an object
    testweapons.OnEnable () (at Assets/scripts/testweapons.cs:31)

    transform.localPosition assign attempt for '!Unarmed' is not valid. Input localPosition is { 0.000000, -Infinity, 0.000000 }.
    UnityEngine.Transform:set_localPosition(Vector3)
    <SelectWeapon>c__Iterator1:MoveNext() (at Assets/RFPSP/Scripts/Weapons/PlayerWeapons.cs:618)
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

    oroutine couldn't be started because the the game object 'testscripts' is inactive!
    UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
    testweapons:OnDisable() (at Assets/scripts/testweapons.cs:37)

    I can't think of how to solve this,
    could you indicate that I'm doing wrong please

    Thank you!
     
  13. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    9,682
    @sebasfreelance - I'm not sure what you're trying to do. I recommend letting Unity call OnEnable and OnDisable automatically; don't call them yourself. (You may want to rename those methods or merge them into a single "SetWeapon" method.)

    Try calling StartCoroutine(playerWeapons.SelectWeapon(#)); only when you need to. Also check if playerWeapons is null first.
     
  14. sebasfreelance

    sebasfreelance

    Joined:
    Aug 27, 2015
    Posts:
    215
    yesterday I was hitting the wall all day long :(

    but finally I got what I wanted! :)

    Thank you very much for your help, it has been very useful

    Best Greetings
     
    TonyLi likes this.
  15. jons190

    jons190

    Joined:
    Sep 13, 2016
    Posts:
    223
    Hey programmers in the group. I've just discovered the logs and am seeing this error. (I'm not a super programmer) How would I go about tracing this back? I'm not sure what exactly the error is.... It looks to be third person weapons and/or maybe the recticle.


    (Filename: Assets/RFPSP/Scripts/Weapons/WeaponPivot.cs Line: 119)

    NullReferenceException: Object reference not set to an instance of an object
    at WeaponPivot.Update () [0x00001] in C:\unity_working\9-27-1029\rewired_test\Assets\RFPSP\Scripts\Weapons\WeaponPivot.cs:119


    Edit: Follow up. I have "crosshair enabled" checked off in FPS player script. When I turn that on, the error goes away... but zoiks! I don't want the crosshair enabled!
     
    Last edited: Oct 8, 2019 at 1:13 AM
  16. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    9,682
    @jons190 - Assuming we're looking at the same version of RFPSP, that line is:

    WeaponBehaviorComponent = PlayerWeaponsComponent.CurrentWeaponBehaviorComponent;

    This means PlayerWeaponsComponent isn't assigned. The script's Start() method assigns PlayerWeaponsComponent the value of CameraControl's playerObj.

    Inspect your Main Camera's CameraControl component. Make sure FPS Player is assigned to Player Obj.
     
  17. jons190

    jons190

    Joined:
    Sep 13, 2016
    Posts:
    223
    -----------------

    Yes it is. seems to be something with the recticle. I've been playing around with that and somehow must have twarged something... not sure what or where.... (usually when these errors pop up, I just copy my fps prefab from a level that has no errors and replace it on the level that is throwing errors to fix. I rarely know how to fix these type of things although my approch doesn't seem to "programmy" but hey... it seems to work...)
     
  18. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    9,682
    Hey, if it works, don't knock it. :)

    Sorry I can't help any further. All I can say is that, at the time that it throws that error, the WeaponPivot script's PlayerWeaponsComponent variable is null.
     
    jons190 likes this.
  19. jons190

    jons190

    Joined:
    Sep 13, 2016
    Posts:
    223
    Alright, for those that are still around. I need some advice. I need to pause the game automatically, when a VR headset is taken off and then restart on vr headset on I have the code that will initiate the pause in OVR MANAGER. But I'm such a duwb programmer, I'm not sure of the best course of action to initiate the pause.


    Somewhere int eh code, there must be a pause function. Does anyone know that location? I'm going to go line by line today, but maybe someone already knows where that is. In FPS input, I have found this line:

    pausePress = ExtraInput.GetButtonDown("Pause");

    But what little I know of programming, tells me, that this is just the button code to initial the pause function and I have to find the pause function in the code and then set something along the lines of
    Pause = true
    Pause = false

    Or something to this effect.

    Also, I am thinking that maybe a better/secondary "architecture" for this would be to freeze the delta time and then unfreeze on pauses end. (which maybe will be exactly the mechanism I find, once I sleuth out the pause function)

    Anyway, any thoughts from a more experienced programmer, would be welcome. Cheers mates! Long live RFPS!


    Alright: In FPSplayer I have found this gem at line 508


    }
    if(Time.timeScale > 0.0f || paused){
    if(!paused){
    menuTime = Time.timeScale;
    }
    Time.timeScale = 0.0f;
    }else{
    Time.timeScale = menuTime;
    }

    This look menu specific, but looks like the start of what I need to access.....
    There also seems to be this method (?????) up on line 189

    FPSPlayer.pauseTime

    that just might be the thing I need to call and set true and untrue. Here goes some trial and error!
     
    Last edited: Oct 11, 2019 at 7:14 PM