Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Realistic FPS Prefab [RELEASED]

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

  1. 99thmonkey

    99thmonkey

    Joined:
    Aug 10, 2012
    Posts:
    524
    llJIMBOBll likes this.
  2. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    576
  3. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    576
    Hi i hate keep asking question but i guess thats how u learn, i've spent most of day trying to use the bullet time when u enter a collider or trigger, but cant seem to make it work, i tryed with on collision enter and then set time to 0.3f and then back to 1 if not but didnt work that good and the gun sounds didnt slow down either... thanx a million if someone can point me in right direction :D

    this is what i have, i have a box with box collider and trigger enabled then this script attached to it
    but says object is not set up in an instance.. thanx :D
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class enterSlowmo : MonoBehaviour {
    5.  
    6.     private FPSPlayer FPSPlayerComponent;
    7.  
    8.     void start (){
    9.         FPSPlayerComponent =  Camera.main.GetComponent<CameraKick>().playerObj.GetComponent<FPSPlayer>();
    10.     }
    11.  
    12.     void OnTriggerEnter(Collider col){
    13.         if (col.gameObject.tag == "Player") {
    14.             FPSPlayerComponent.bulletTimeActive = (true);
    15.         }
    16.     }
    17.  
    18.     void OnTriggerExit(Collider col){
    19.         if (col.gameObject.tag == "Player") {
    20.             FPSPlayerComponent.bulletTimeActive = (false);
    21.         }
    22.     }
    23. }
     
    Last edited: Oct 3, 2015
  4. Rambo Games

    Rambo Games

    Joined:
    Oct 4, 2015
    Posts:
    1
    I have an error.This is showned when I play(Input button Left is not set up)
     
  5. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    576
    re-import the asset and make sure to override the input settings
     
  6. Takahama

    Takahama

    Joined:
    Feb 18, 2014
    Posts:
    166
    Hmm
    Add something like "var" stuff to drag your collider data in script ?
     
  7. canaljuegos32

    canaljuegos32

    Joined:
    Jun 29, 2015
    Posts:
    53
    Is there a way to make enemies shoot spells (fireball and so)?.
     
  8. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    576
    hey speaking of shooting fire, i recently purchased fps weapons 2.0 which is perfect for rfps by the way, it comes with a flamethrower and rpg has all scripts to make it work im wondering how i would make it work with weapon behavior or can i not use that script and just use the scripts that came with it, unless theres a way to choose the projectile?

    also a hit indicator would be amazing, espec for ai that shoot u
     
  9. canaljuegos32

    canaljuegos32

    Joined:
    Jun 29, 2015
    Posts:
    53
    I saw a vid of UFPS in which the muzzle of player gun is a prefab, so that means any magic effec i think. So i wonder if is posible in RFPS and add it for enemy NPCS also. It opens many possibilities for the asset too.
     
    llJIMBOBll likes this.
  10. funkman

    funkman

    Joined:
    Aug 25, 2015
    Posts:
    1
    Hey, hello all, nice to see this is an active thread and asset.
    Also, will use this occasion to send regards to authors - very nice work!

    I've just finished up prototype for a mobile shooter with this, yet made one, obviously, strange mistake.
    I've removed all non needed weapons from scene and list in FPS Weapons and adjusted everything (array, first, second weapon etc) and now I cannot get sniper to zoom. Every other weapon works - iron sight works, but not on the sniper.

    I've searched crazy through code, it seems to me that perhaps something left unreferenced when I removed prefab references from scene, but am not able to figure out what is missing. No errors either, zoom simply wont work.

    Did anyone had similar issue or perhaps knows where to look? Thanks in advance.

    EDIT - FIXED
    OK - for those who ever get to same issue - it seems that you NEED to have !Unarmed as well in the weapon list, then if you like - want to use 2 weapons only switch indexes to corresponding weapon numbers, but always keep !Unarmed as first. I must have missed it in the documentation or code, so I'm not familiar with why this is necessary but it works.

    That was kinda fast, I tried that immediately after posting message :D
    Regards
     
    Last edited: Oct 11, 2015
    Deleted User and Baraff like this.
  11. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    251
    Anyone know why I get this graphic problem with the bullet marks.
    They seem to fade OK and are none visible, but then it is like they fade back onto the screen and appear like this. Almost like inverted colors.

    This happens on all bullet marks and it also seem to happen occasionally with the gun flash texture too.

    This is with HDR on.
     

    Attached Files:

  12. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    576
    Yes, im having this issue too, with HDR on, not sure if HDR makes a difference.. really annoying tho xd
     
  13. Deleted User

    Deleted User

    Guest

    Thanks for the suggestion Gua. A var in FPSPlayer.cs has been added called showHpUnderZero which can be used to customize this behavior.


    Glad you fixed the problem Baraff, this is a nice solution and will probably be in the next version too.


    Thanks Takahama, you've found a few bugs in the past too, which has really helped :) You can fix this by making a change around line 131 of MineExplosion.cs:

    Code (CSharp):
    1.                         if(hitColliders[i].GetComponent<Collider>().gameObject.GetComponent<BreakableObject>()){
    2.                             hitColliders[i].GetComponent<Collider>().gameObject.GetComponent<BreakableObject>().ApplyDamage(explosionDamage);
    3.                         }else if(hitColliders[i].GetComponent<Collider>().gameObject.GetComponent<ExplosiveObject>()){//change here
    4.                             hitColliders[i].GetComponent<Collider>().gameObject.GetComponent<ExplosiveObject>().ApplyDamage(explosionDamage);
    5.                         }else if(hitColliders[i].GetComponent<Collider>().gameObject.GetComponent<MineExplosion>()){
    6.                             hitColliders[i].GetComponent<Collider>().gameObject.GetComponent<MineExplosion>().ApplyDamage(explosionDamage);
    7.                         }

    Wow Ratboy601, this is one of the best web players I 've seen! Very nice work! I'll PM you with an alternate hand model that holds the flashlight horizontally, which will be included in the next version. if anyone else would like the flashlight hand model seen in the new demo for the Realistic FPS Prefab, please send a PM.


    Nice solution Deppex, this will be fixed in the next version.


    When damaging the player, you should call the ApplyDamage function of FPSPlayer.cs, which will properly detect if the player ran out of hitpoints and call the Die function in that script.


    Hi llJIMBOBll, have you checked in the script excecution order that your new script is lower in the list (excecuted later) than CameraKick.cs? If not, your script might be trying to get the FPSPlayerComponent reference before CameraKick.cs had aquired it in the Start() function. Hope that helps.


    Sure canaljuegos32, in the FireOneShot() function of NPCAttack.cs, there is a raycast that is used to determine if the NPC has hit their target. You can replace this with code that instantiates a fireball object with forward velocity and a script attached that checks its OnCollisionEnter() function to apply damage to other NPCs and the player. This is a basic description, but hopefully will give you some ideas.


    Good to hear you're enjoying the project funkman and that you resolved your issue! Please let us know if you have any other questions.


    Hi Baraff, we noticed this too. It has something to do with the alpha color of the materials going into negative values when HDR is enabled.

    In WeaponBehavior.cs around line 810, you can make this addition:

    Code (CSharp):
    1.                 //Fade out muzzle flash alpha
    2.                 if(muzzleFlash){
    3.                     if (muzzleRendererComponent.enabled){
    4.                         if(muzzleFlashColor.a > 0.0f){
    5.                             muzzleFlashColor.a -= muzzleFlashReduction * Time.deltaTime;
    6.                             if(muzzleFlashColor.a < 0.0f){muzzleFlashColor.a = 0.0f;}//prevent alpha from going into negative values
    7.                             muzzleRendererComponent.material.SetColor("_TintColor", muzzleFlashColor);
    8.                         }else{
    9.                             muzzleRendererComponent.enabled = false;//disable muzzle flash object after alpha has faded
    10.                         }
    11.                     }
    12.                 }
    And in FadeOutDecals.cs, line 37, please make this correction:

    Code (CSharp):
    1.         if(startTime + markDuration < Time.time){
    2.             tempColor.a -= Time.deltaTime;//fade out the color's alpha amount
    3.             RendererComponent.material.color = tempColor;//set the material's color to the value(s) of our temporary color vector
    4.             tempColor.a = Mathf.Clamp(tempColor.a, 0.0f, 255.0f);//prevent alpha from going into negative values
    5.         }
    And the muzzle flash and decals should not get too bright anymore.


    As far as a review of development progress, here are the changes so far for the upcoming version:
    • Footstep sounds that change on terrain, based on texture (grass, dirt, gravel, sand, stone)

    • Weapon pivot code which adds slight weapon "nodding" when walking, a new leading weapon sway type, and deadzone aiming, to make the weapon move independently from the camera

    • Object pooling system for ejected shells and impact effects, can also be used for projectiles

    • Slight weapon kick / twist along the roll angle

    • Flashlight model with attack animations

    • Weapon material fading to simulate being in shadow/indoors for the 2 camera setup. This is done because the separate weapon camera doesn't receive shadows from the game world, but lights still affect the weapon models. There are ways to do this by clearing the depth buffer with a custom shader, but the current solution is simple and works for now. The 2 camera setup supports scenes of ~ 20 mi ² / 32 km ² before floating point error starts to make weapon models jitter. This also allows the main camera to use a much higher near clip plane value, which reduces z fighting on close surfaces like water on a distant beach. The single camera prefab is also available, which supports a smaller scene size, but receives shadows from world geometry.
    Here's the demo to try out some new features. Deadzone aiming is enabled by default, but you can press the Alt key to toggle it. The Y key toggles deadzone aiming for zooming and the U key toggles between weapon sway modes: the existing "lagging" sway which gives a feeling of weapon weight, and the "leading" sway mode, which responds well with joystick input by pushing the weapon slightly in the look direction. Thanks for trying it out!

    Realistic FPS Prefab 1.23 Web Player Demo

    Edit: A version of the Realistic FPS Prefab that is compatible with Unity 4 is available, please contact us if you need it.
     
    Last edited by a moderator: Oct 14, 2015
    llJIMBOBll, Defcon44 and TonyLi like this.
  14. canaljuegos32

    canaljuegos32

    Joined:
    Jun 29, 2015
    Posts:
    53
    Idea yes, but dont know how to make it since im not a coder. Best what i did was load a particlesystem with the muzzleflash (lol) that dont do damage and dont point to player if he go to the house roof for example. Also turned enemy soldier into an angry energy bolt:

     
  15. Defcon44

    Defcon44

    Joined:
    Aug 19, 2013
    Posts:
    400
    Nice to see you Azuline ;)

    Good news today, thanks :)
     
    Deleted User likes this.
  16. Takahama

    Takahama

    Joined:
    Feb 18, 2014
    Posts:
    166
    Yay! :D
    Another glitch ._.
    Light can pass through objects :/
    RFPSP1,23.png
    @Azuline Studios Follow player checkbox is in future plans list ? :p
     
    Defcon44 likes this.
  17. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    378
    I'm using RFPS 1.21 and after upgrade to Unity 5.2.1p3 I've noticed that footstep sound lag behind player. It's especially noticeable when I strafe. When I strafe left, I hear footsteps sounds in my right ear, when I strafe right I hear footsteps in my left ear. Did someone else also encountered that problem?

    update: I did identified the core of a problem. By default a Unity 5.14 creates a 2d sound when AudioSource.PlayClipAtPoint is used, while Unity 5.21p3 creates 3d sound. I'm not a coder, so I'll appreciate if someone is willing to help me fix this issue.
     

    Attached Files:

    Last edited: Oct 15, 2015
  18. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    10,479
    Could something else be happening? I just tried RFPS 1.21 updated to Unity 5.1.1, and it seems to work correctly. It plays the sound I'm baking lightmaps on the PC with 5.2.1, and I haven't installed 5.2.1 on this PC yet, so the best I can test with is 5.1.1. The AudioSource.PlayClipAtPoint() lines should play the clip at the camera position.

    You can modify it to use the !!!FPSPlayer's AudioSource. Here are the edits:
    1. Add this line above void Start():
      Code (csharp):
      1. public AudioSource audioSource;
    2. Add this line as the last line in the Start() method:
      Code (csharp):
      1. if (audioSource == null) audioSource = GetComponent<AudioSource>();
    3. Replace all 4 AudioSource.PlayClipAtPoint lines with audioSource.PlayOneShot, similar to this:
      Replace:
      Code (csharp):
      1. AudioSource.PlayClipAtPoint(footStepClip, cameraTransform.position, volumeAmt);
      with:
      Code (csharp):
      1. audioSource.PlayOneShot(footStepClip, volumeAmt);
     
  19. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    378
    Thank you very much! If a recall correctly RFPS uses PlayClipAtPoint for almost all player sounds. This creates a need for a lot of audio sources. Maybe there's an alternative, like making similar to PlayClipAtPoint, but with ability to set Spatial Blend?
     
    Last edited: Oct 15, 2015
  20. Deppex

    Deppex

    Joined:
    May 31, 2015
    Posts:
    21
    Hey guys
    I want to SetActive(true) and SetActive(false) spawned NPC.
    but
    If I disarm him and then arming it does nothing.
    How do I do that

    Solved...
    this is solution


    Code (CSharp):
    1.  
    2.  
    3.     public bool activate = false;
    4.     [HideInInspector]
    5.     public Transform distanceFrom;
    6.     [HideInInspector]
    7.     public float disableCheckInterval = 5.0f;
    8.     [HideInInspector]
    9.     public float enableCheckInterval = 1.0f;
    10.     public int distanceDisable = 100;
    11.  
    12. void Start(){
    13. distanceFrom = Camera.main.transform;
    14.         InvokeRepeating("CheckDisable", disableCheckInterval + (Random.value * disableCheckInterval), disableCheckInterval);
    15.         InvokeRepeating("CheckEnable", enableCheckInterval + (Random.value * enableCheckInterval), enableCheckInterval);  
    16.  
    17. }
    18.  
    19. public void CheckDisable(){
    20.         if (gameObject.activeInHierarchy && (transform.position - distanceFrom.position).sqrMagnitude > distanceDisable * distanceDisable){
    21.             activate = true;
    22.             gameObject.SetActive(false);
    23.         }
    24.     }
    25.  
    26.     public void CheckEnable(){
    27.         if (!gameObject.activeInHierarchy && (transform.position - distanceFrom.position).sqrMagnitude < distanceDisable * distanceDisable){
    28.        
    29.             if(activate){
    30.                 gameObject.SetActive(true);
    31.              
    32.               if(spawned){
    33.                   StartCoroutine(SpawnNPC());
    34.                 }else if(patrolOnce){
    35.                     StartCoroutine(StandWatch());
    36.                 }else if(walkOnPatrol){
    37.                     StartCoroutine(Patrol());
    38.                 }else if(huntPlayer){
    39.                     return;
    40.                 }
    41.                 activate = false;
    42.             }
    43.  
    44.         }
    45.     }
     
    Last edited: Oct 15, 2015
  21. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    10,479
    This would require a lot of changes to the RFPS 1.21 scripts. Does 1.22+ work any better for you in Unity 5.2.1? Also, patch version 5.2.1p4 is now out. You can check if that fixes any issues, too.
     
  22. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    378
    I doesn't fixed it. I'm not even sure that it's will be qualified as issue by Unity. Upgrading RFPS is not an option for me, cause I've made a lot of changes to scripts and added a lot of extra functionality using Playmaker, that will probably break if I'll upgrade it.
     
    Last edited: Oct 15, 2015
  23. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    10,479
    Would it help to change the global Rolloff Scale in Edit > Project Settings > Audio?

    It would probably be more accurate to fix each call to AudioSource.PlayClipAtPoint in all scripts, but changing the global value might be a good enough fix.
     
  24. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    10,479
    Instead of manually changing each AudioSource.PlayClipAtPoint, you could drop in a script like this instead:
    Code (csharp):
    1. using UnityEngine;
    2.  
    3. public static class GuaAudioSource {
    4.  
    5.     public static void Play2DClipAtPoint(AudioClip clip, Vector3 position, float volume) {
    6.         var temp = new GameObject("OneShotAudio");
    7.         temp.transform.position = position;
    8.         var audioSource = temp.AddComponent<AudioSource>();
    9.         audioSource.clip = clip;
    10.         audioSource.volume = volume;
    11.         audioSource.spatialBlend = 0;
    12.         audioSource.Play();
    13.         Object.Destroy(temp, clip.length);
    14.     }
    15. }
    (I just typed it in here; it's not tested yet.)

    In all files, globally replace:
    Code (csharp):
    1. AudioSource.PlayClipAtPoint(
    with:
    Code (csharp):
    1. GuaAudioSource.Play2DClipAtPoint(
    Back up your project before trying a big change like this!

    EDIT: Fixed call to Destroy().
     
    Last edited: Oct 15, 2015
    Gua likes this.
  25. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    378
    Thank you very much! My programmer friend helped me solve some issues related to it. Here's what the final version looks like if some one need it

    Code (csharp):
    1.  
    2. using UnityEngine;
    3.  
    4. public static class GuaAudioSource {
    5.  
    6.     public static void Play2DClipAtPoint(AudioClip clip, Vector3 position, float volume = 1f) {
    7.         var temp = new GameObject("OneShotAudio");
    8.         temp.transform.position = position;
    9.         var audioSource = temp.AddComponent<AudioSource>();
    10.         audioSource.clip = clip;
    11.         audioSource.volume = volume;
    12.         audioSource.spatialBlend = 0;
    13.         audioSource.Play();
    14.         GameObject.Destroy(temp, clip.length);
    15.     }
    16. }
    17.  
     
    Deleted User and TonyLi like this.
  26. SteveRyu

    SteveRyu

    Joined:
    Apr 9, 2014
    Posts:
    121
    @TonyLi Health UI Slider and Ammotext UI Text isn't work on 1.22...
     
  27. Deleted User

    Deleted User

    Guest

    Nice job canaljuegos32, maybe it could be an elemental enemy of some kind. As far as NPCs and the Player shooting actual projectile objects like fireballs, this feature is currently being developed and should be available in the next update. Thanks for your patience.


    Thanks Takahama, we'll have to look into the spotlight issue. It might be happening because the light isn't set up to cast shadows, which would be cast by foreground objects like in your screenshot. Player following, friendly AI is also being worked on for the next update.
     
    llJIMBOBll likes this.
  28. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    10,479
    Hi - For Health UI Slider, make sure your scene has a GameObject named "Healthbar". You can change line 19 of HealthText.cs to this to handle it more gracefully if Healthbar is missing:
    Code (csharp):
    1. var sliderGO = GameObject.Find("Healthbar");
    2. slider = (sliderGO == null) ? null : sliderGO.GetComponent<UnityEngine.UI.Slider>();
    And change this line in Update:
    Code (csharp):
    1. if (slider != null) slider.value = Mathf.Clamp(healthGui / 100, 0, 1);
    For the ammo text, the line changed from 319 to 343. Add this at line 343 of WeaponBehavior.cs:
    Code (csharp):
    1. if (AmmoText1 != null) AmmoText1.uiText = GetComponentInChildren<UnityEngine.UI.Text>();
    And change line 234 to:
    Code (csharp):
    1. if (AmmoText1 != null) AmmoText1.uiText = GetComponentInChildren<UnityEngine.UI.Text>();
    References:
     
  29. Takahama

    Takahama

    Joined:
    Feb 18, 2014
    Posts:
    166
    Awesome! :D
    Any plans for bullet shells ? i fire my gun, while shell in air i'll turn my mouse fast and shell still follow my gun :/
    EDIT: this means its work on progress ? "Object pooling system for ejected shells and impact effects, can also be used for projectiles"
     
  30. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    576
    @Azuline Studios If you take requests, any chance of some sort of hit detector for when u get by a ai with a gun. That would be amazing, anyway cant wait to use flamethrower and rpg xd :D Thanx
     
  31. Takahama

    Takahama

    Joined:
    Feb 18, 2014
    Posts:
    166
    Dont forget about bulletdrop!! :D
    And crosshair size change when we fire our gun is needed feature :D
    Edit: Hitmark too! Tons of hitmarks..xD
     
    llJIMBOBll likes this.
  32. canaljuegos32

    canaljuegos32

    Joined:
    Jun 29, 2015
    Posts:
    53
    Is there a way to run backwards or sides?. I mean by pressing shift player only runs forward. To evade proyectiles is a must.
     
  33. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    576
    i found a epic major bug... if u stand on top of a barrel, hold z to pick it up, look up and start walking, ur start walking up in the air with the barrel xD, i tested in 1.23 and its in there too

    http://postimg.org/image/6mk1287pf/
     
  34. Takahama

    Takahama

    Joined:
    Feb 18, 2014
    Posts:
    166
    Tested and its not only barrel :D wooden boxes do same thing but i tryed without walking just step on them, grab it and looked up! :D
    @Azuline Studios as we all know RFPSP's Mp5 has flashlight built in. So can we put flashlight with on off switch ? (i know its a simple script but better included by makers of this perfect kit)

    EDIT: This glitch also works on current version ._.

    IMPORTANT: if you have an Origin (EA) account, change for information ASAP because hackers
    reached thousands of account information and released them in some forums.
     
    Last edited: Oct 19, 2015
  35. Takahama

    Takahama

    Joined:
    Feb 18, 2014
    Posts:
    166
    @Azuline Studios i tryed to make some destraction stuff
    i used breakable object script for make destructible lamp. But there a delay removing object from scene like after destroying lamp light disappears after few seconds. Any tips ? :C
    Oh and i make a cover using CharacterDamage and AI scripts xD it breaks when take enough damage by replacing some rock models but its a bit complex ._. (well not that much but.. you know)
    My request is this: Plase make a scripts that destroy stuff and replace a model :/ (Like instant disappear light and cover stuff)
     
  36. Deppex

    Deppex

    Joined:
    May 31, 2015
    Posts:
    21
    Hi Tony Li
    I made it in this way

    For me it works good.
    Code (CSharp):
    1. //HealthText.cs by Azuline Studios© All Rights Reserved
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class HealthText : MonoBehaviour {
    6.     //draw health amount on screen
    7.     public float healthGui;
    8.     private float oldHealthGui = -512;
    9.     public Color textColor;
    10.     public float horizontalOffset = 0.0425f;
    11.     public float verticalOffset = 0.075f;
    12.  
    13.     public float sliderHorizontalOffset = 0.044f;
    14.     public float sliderVerticalOffset = 0.95f;
    15.  
    16.     public bool showNegativeHP = true;
    17.    
    18.  
    19.     void Start(){
    20.         GetComponent<GUIText>().material.color = textColor;
    21.         GetComponent<GUIText> ().fontSize = 22;
    22.         oldHealthGui = -512;
    23.     }
    24.  
    25.     void OnGUI() {
    26.         if (healthGui > 0.0f ) {
    27.             GUI.HorizontalSlider (new Rect (Screen.width * sliderHorizontalOffset, Screen.height * sliderVerticalOffset, 135, 100), healthGui, 0.0F, 100.0F);
    28.         }
    29.     }
    30.  
    31.     void Update (){
    32.  
    33.         //only update GUIText if value to be displayed has changed
    34.         if(healthGui != oldHealthGui){
    35.             if(healthGui < 0.0f && !showNegativeHP){
    36.                 GetComponent<GUIText>().text = "Health : 0";
    37.             }else{
    38.                 GetComponent<GUIText>().text = "Health : "+ healthGui.ToString();
    39.             }
    40.             GetComponent<GUIText>().pixelOffset = new Vector2 (Screen.width * horizontalOffset, Screen.height * verticalOffset);
    41.             oldHealthGui = healthGui;
    42.         }
    43.     }
    44. }
     
  37. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    10,479
    Thanks for sharing the code! BTW, if you add these 2 lines to the Start() section:
    Code (csharp):
    1. private GUIText guiText; // <-- Add this line (1/2)...
    2.  
    3. void Start(){
    4.     guiText = GetComponent<GUIText>(); // <-- ...and this line (2/2).
    Then in your Update() section you can replace all instances of "GetComponent<GUIText>()" with "guiText". By caching this value instead of searching for it three times every frame update, you may boost your framerate.
     
  38. Black-Lodge-Games

    Black-Lodge-Games

    Joined:
    Nov 22, 2013
    Posts:
    80
    Any word on Oculus Rift DK2 support? I saw a question and reply talking about it a few pages back, but nothing since then.
     
  39. OZAV

    OZAV

    Joined:
    Aug 9, 2013
    Posts:
    196
    The link to demo car is broken, anyone knows link to (proper) RFPS Car solution ?
     
  40. Defcon44

    Defcon44

    Joined:
    Aug 19, 2013
    Posts:
    400
    You can found this TUTO on the azulineblog, but i don't know if this work with DK 2 :s
     
  41. Black-Lodge-Games

    Black-Lodge-Games

    Joined:
    Nov 22, 2013
    Posts:
    80
    Thanks! Oculus development has moved so quickly that even stuff from earlier in 2015 is completely useless in many cases, especially because I've been staying as bleeding edge as possible with it. Since somewhere around Unity 5.1 (I can't remember) Unity has shipped with VR integration built in, so it's really just a matter of checking a box to enable it. Most of that tutorial is now superseded by checking the VR setting in Player Settings. Thanks again though, I appreciate the effort!

    I tried !RFPS with Oculus DK2 using 0.7.0 SDK on Unity 5.2.0p on Windows 10 Enterprise in a blank new project. Worked very well out of the box. However, the main issue is that the cross hairs follow where you are looking (which is good) but the gun doesn't (which is the problem, since you're forced to update the gun position with the right stick instead of it just being where you are looking) so I'll need to do some editing of !RFPS to get the correct expected VR head movement interaction.

    EDIT: Actually, there are a few nuggets that might help on that tutorial page when it comes to editing the firing position!
     
  42. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    10,479
    I've been working a bit with VR. I would prefer if the player's entire body followed where you're looking. Otherwise I can end up looking one way and walking "forward" in another direction, which I find very disorienting. I think the key may be to write a script that checks the camera Y rotation every Update. If it's different from the player's, rotate the player to match the camera so the local camera Y is 0.
     
    Black-Lodge-Games likes this.
  43. Black-Lodge-Games

    Black-Lodge-Games

    Joined:
    Nov 22, 2013
    Posts:
    80
    Yeah, I know exactly what you mean and that describes the issue (and solution) in more complete terms than my attempt, as that is essentially the behavior of RFPS that I am experiencing. Still, I was surprised that RFPS worked as well as it did out of the box, as other than that it worked perfectly! Most of the other camera systems I've messed with have a hard time functioning at all without doing some major recoding.

    In an unrelated side-note, I've been kicking myself in the butt for over a year now for choosing a different dialog system other than yours. I hand coded compatibility with this other dialog system and RFPS and then shortly afterwards you added support for RFPS. Looking through your Dialog System for Unity integration page, it seems you've covered some of the most fantastic assets out there, many of which I own. If I would've chosen your asset, it would've saved me several weeks of work! I haven't had an asset budget in several months, but when we allocate more next production cycle, I'll definitely be picking up both your Dialogue System and Love/Hate to add to our tool chain. Glad to see that you're still around and as active as ever!</sidenote>
     
  44. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    10,479
    Thanks!

    If I can carve out a few minutes tomorrow, I'm going to try a VR script with RFPS. If it works out, I'll post it here!
     
    Black-Lodge-Games likes this.
  45. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    378
    Is there an option to invert mouse in RFPS 1.21? And if there is non, was it added to newer versions?
     
    Last edited: Oct 24, 2015
  46. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    10,479
    I don't think there's an invert option. You can add it yourself to InputControl.cs. In 1.21, it's on line 182. In 1.22+, it's on line 190. Change this:
    Code (csharp):
    1. lookY = Input.GetAxisRaw("Mouse Y") + AccelerateInput(lookInput.y);
    to this:
    Code (csharp):
    1. lookY = -(Input.GetAxisRaw("Mouse Y") + AccelerateInput(lookInput.y));
    Better yet, you could add a checkbox:
    Code (csharp):
    1. public bool invertMouseY;
    and then change the line to this:
    Code (csharp):
    1. lookY = Input.GetAxisRaw("Mouse Y") + AccelerateInput(lookInput.y);
    2. if (invertMouseY) lookY *= -1;
    If you make any of these changes, please test them out. I didn't do a thorough test, and it's possible that you only want to invert Input.GetAxisRaw, not the entire lookY value.
     
    Gua likes this.
  47. mentolatux

    mentolatux

    Joined:
    Nov 2, 2014
    Posts:
    236
    anyone added button control mobile to this kit to make an android game ?
     
  48. poison77

    poison77

    Joined:
    Dec 24, 2013
    Posts:
    39
    I did, Control Freak asset on Unity Asset Store works just fine ;)
     
  49. mentolatux

    mentolatux

    Joined:
    Nov 2, 2014
    Posts:
    236
    button is working but i change map and zombie go to wall and not chase in me correct
     
  50. The-Sovereign

    The-Sovereign

    Joined:
    Jul 15, 2015
    Posts:
    24
    You have to Bake your scene.
     
unityunity