Search Unity

Realistic FPS Prefab [RELEASED]

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

  1. inglipX

    inglipX

    Joined:
    Aug 9, 2012
    Posts:
    30
    Hello, thanks for your reply. I've tried your solutions but they didnt work.... :(. In windowed standalone mode i can pick objects up with my mouse button but in fullscreen standalone i cannot. Making the code change doesnt fix it..... I am using my own cubes that are rigidbodies, which i can drag in the editor.
     
    Last edited: Jun 3, 2013
  2. Deleted User

    Deleted User

    Guest

    Hi inglipX, what you're describing is not something I've been able to recreate in Unity 3.5 or 4.x on my setup, so I will do my best to work with you guys to gather information and figure it out. First of all, are you not able to drag all objects in full screen mode, or just the cubes that you've created? If it's only the cubes, please make sure that they are set to layer 10, the world collision layer.

    You also mention that the rigidbody dragging does work in the stand alone when running in windowed mode? Could you please try enabling or disabling the Capture Single Screen option in your Player Settings for your standalone build?

    Also, when you can't drag objects in full screen mode, can you still pick up objects by pressing E when the hand icon appears? If so, the issue might not be with the camera raycast because the item pick up and object dragging behaviors use the same raycasting direction.

    If that still doesn't work inglipX and Dari, could you please provide some more information about your setup? Such as, if you are using dual monitors, the aspect ratio of your full screen resolution, if you have VSync disabled or enabled in the project's quality settings and your video card driver settings, the OS you are running, and what, if any, changes you've made to the original setup of the realistic FPS Prefab?

    You might also want to upgrade to the newest version of Unity if you haven't already and try disabling or enabling the Display Resolution Dialog in the Player Settings as described in this post. Hopefully that will shed some light on the situation, but please let me know if you're still encountering the issue.


    Thanks Dari, we noticed that too and it has been changed for the next version. To fix it yourself, you can find this code in Ironsights.cs around line 297:

    Code (csharp):
    1.            //if zoomed
    2.             //check time of weapon sprinting anim to make weapon return to center, then zoom normally
    3.             if(FPSPlayerComponent.zoomed
    4.              !reloading
    5.              gunAnimTime < 0.35f
    and change it to this:

    Code (csharp):
    1.             //if zoomed
    2.             //check time of weapon sprinting anim to make weapon return to center, then zoom normally
    3.             if(FPSPlayerComponent.zoomed
    4.              PlayerWeaponsComponent.switchTime + WeaponBehaviorComponent.readyTime < Time.time//don't raise sights when readying weapon
    5.              !reloading
    6.              gunAnimTime < 0.35f
     
    Last edited by a moderator: Jun 4, 2013
  3. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    Thanks, but did you test it? It doesn't work, Errors:

    Assets/!Realistic FPS Prefab Files/Scripts/Weapons/Ironsights.cs(296,43): error CS0122: `PlayerWeapons.switchTime' is inaccessible due to its protection level
     
  4. Deleted User

    Deleted User

    Guest

    Sorry about that Dari, the switchTime variable declaration also needs to be updated in PlayerWeapons.cs at line 27 from this:

    Code (csharp):
    1.  
    2.     private float switchTime = 0.000f;//time that weapon switch started
    to this:

    Code (csharp):
    1.     [HideInInspector]
    2.     public float switchTime = 0.000f;//time that weapon switch started
    Forgot that I had made that change in PlayerWeapons.cs as well :( If you ever get the kind of error that says " x is inaccessible due to its protection level" it means that a private variable or function/member function needs to be changed to public when it is being declared or initialized, so other code outside that class can access it. the "[HideInInspector]" part added above the switchTime declaration hides the variable because the inspector always displays public variables. We can hide switchTime from the inspector because we don't need to customize it.
     
    Last edited by a moderator: Jun 4, 2013
  5. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    676
    Hi Azuline!

    Currently, FPSPlayer uses Pain Color to show when the Player takes damage on the screen. Any plans to add a field for displaying a pain overlay image (eg. bloody vignette, etc.) with the ability to set its fade time? And some camera flinching when taking pain? :)
     
  6. inglipX

    inglipX

    Joined:
    Aug 9, 2012
    Posts:
    30
    I dont use vsync or multiplie monitors. I tried setting the settings you suggested but it hasnt worked. I can still pick up ammo and guns with E and i can equip guns. Its weird....full screen i cant move objects but i can still pick up items like ammo. Windowed mode i can move objects with Z also. These objects i wish to drag are not pickups (some of them) Ammo is a pickup but the cube (crate) i wish to drag is not. I can drag it fine in editor.... Please help. Maybe i need to raycast from the mouse pos ?
     
  7. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    No problem! Thanks it works fine, can't wait for the update, the droppable weapons sounds very interesting :)
     
  8. Deleted User

    Deleted User

    Guest

    Sure lod3, a pain overlay image is definitely possible. I'll add it to the list for a future update. There is a subtle camera flinch in the prefab now, but for the next update the flinch amount will be an editable variable of the FPSPlayer component that is multiplied by the amount of damage taken.


    Hi inglipX, you mentioned that you aren't using VSync. Do you know what framerate your project is running at when you are experiencing the object dragging issue? The prefab was developed with VSync enabled and capping the framerate at 75 most of the time and occasionally at higher framerates when testing for framerate independence. I just did a test by disabling VSync on my setup and at framerates higher than around 250, object dragging started to randomly not work.

    What I did to fix it was change line 21 of DragRigidbody.cs from this:

    Code (csharp):
    1.     void FixedUpdate (){  
    to this:

    Code (csharp):
    1.     void Update (){
    If that still doesn't solve the problem, I have a test script I can send you that uses the mouse position instead of the camera position as the starting point for the object detection raycast. Testing this script would at least rule out the raycast as being the source of the problem. Thanks for your patience.


    The droppable weapons are pretty neat. That and the option to limit the amount of weapons the player can carry adds some fun gameplay possibilities.
     
  9. NukeOrama

    NukeOrama

    Joined:
    Jun 5, 2013
    Posts:
    3
    Hi Azuline! Thanks so much for this FPS Prefab, it is truly awesome. I am new to unity, and have been having a lot of fun with it and playing around with the included demo scene. I am now starting to use the FPS Prefab in my first Unity Project. I have an Oculus Rift Dev kit and my first project will make use of it. So my question is, is it possible to get the Oculus Rift FPS cameras working with Realistic FPS Prefab? I have spent a couple of hours trying without success.
     
  10. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    I forgot how to set the life time of the bullet mark and shell, can you help me find it? :)
     
  11. inglipX

    inglipX

    Joined:
    Aug 9, 2012
    Posts:
    30
    Thank you Azuline! Changed FixedUpdate to Update actually fixed the issue. YAY!
     
  12. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    676
    @Azuline

    (In case you don't have PM notifications on), could you check the last two PMs I sent, please? :)
     
  13. inglipX

    inglipX

    Joined:
    Aug 9, 2012
    Posts:
    30
    Hello Azuline!

    How can i make my player stop sprinting if i lift the left shift button up while im moving? Currently if i hold W and left shift I sprint but if i let go of left shift and still hold W then my player is still sprinting instead of back to walking. How can i fix this?

    Additionally, why do the guns seem to shiver (Shake in place) when i am holding them?
     
    Last edited: Jun 7, 2013
  14. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    They shake because you didn't put the Player on the x0 y0 z0 position or close to that. I don't know why that happens, but I found how to fix it! :D
     
  15. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    Any idea why it won't show the cursor when I build the scene, in script it says it does:

    Code (csharp):
    1. var mainMenuSceneName : String;
    2. var pauseMenuFont : Font;
    3. private var pauseEnabled = false;          
    4.  
    5. function Start(){
    6.     pauseEnabled = false;
    7.     Time.timeScale = 1;
    8.     AudioListener.volume = 1;
    9.     Screen.showCursor = false;
    10. }
    11.  
    12. function Update(){
    13.  
    14.     //check if pause button (escape key) is pressed
    15.     if(Input.GetKeyDown("escape")){
    16.    
    17.         //check if game is already paused      
    18.         if(pauseEnabled == true){
    19.             //unpause the game
    20.             pauseEnabled = false;
    21.             Time.timeScale = 1;
    22.             AudioListener.volume = 1;
    23.             Screen.showCursor = false;         
    24.         }
    25.        
    26.         //else if game isn't paused, then pause it
    27.         else if(pauseEnabled == false){
    28.             pauseEnabled = true;
    29.             AudioListener.volume = 0;
    30.             Time.timeScale = 0;
    31.             Screen.showCursor = true;
    32.         }
    33.     }
    34. }
    35.  
    36. private var showGraphicsDropDown = false;
    37.  
    38. function OnGUI(){
    39.  
    40. GUI.skin.box.font = pauseMenuFont;
    41. GUI.skin.button.font = pauseMenuFont;
    42.  
    43.     if(pauseEnabled == true){
    44.        
    45.         //Make a background box
    46.         GUI.Box(Rect(Screen.width /2 - 100,Screen.height /2 - 100,250,200), "Pause Menu");
    47.        
    48.         //Make Main Menu button
    49.         if(GUI.Button(Rect(Screen.width /2 - 100,Screen.height /2 - 50,250,50), "Main Menu")){
    50.             Application.LoadLevel(mainMenuSceneName);
    51.         }
    52.        
    53.         //Make Change Graphics Quality button
    54.             if(GUI.Button(Rect(Screen.width /2 - 100,Screen.height /2 ,250,50), "Change Graphics Quality")){
    55.            
    56.             if(showGraphicsDropDown == false){
    57.                 showGraphicsDropDown = true;
    58.             }
    59.             else{
    60.                 showGraphicsDropDown = false;
    61.             }
    62.         }
    63.        
    64.         //Create the Graphics settings buttons, these won't show automatically, they will be called when
    65.         //the user clicks on the "Change Graphics Quality" Button, and then dissapear when they click
    66.         //on it again....
    67.         if(showGraphicsDropDown == true){
    68.             if(GUI.Button(Rect(Screen.width /2 + 150,Screen.height /2 ,250,50), "Fastest")){
    69.                 QualitySettings.currentLevel = QualityLevel.Fastest;
    70.             }
    71.             if(GUI.Button(Rect(Screen.width /2 + 150,Screen.height /2 + 50,250,50), "Fast")){
    72.                 QualitySettings.currentLevel = QualityLevel.Fast;
    73.             }
    74.             if(GUI.Button(Rect(Screen.width /2 + 150,Screen.height /2 + 100,250,50), "Simple")){
    75.                 QualitySettings.currentLevel = QualityLevel.Simple;
    76.             }
    77.             if(GUI.Button(Rect(Screen.width /2 + 150,Screen.height /2 + 150,250,50), "Good")){
    78.                 QualitySettings.currentLevel = QualityLevel.Good;
    79.             }
    80.             if(GUI.Button(Rect(Screen.width /2 + 150,Screen.height /2 + 200,250,50), "Beautiful")){
    81.                 QualitySettings.currentLevel = QualityLevel.Beautiful;
    82.             }
    83.             if(GUI.Button(Rect(Screen.width /2 + 150,Screen.height /2 + 250,250,50), "Fantastic")){
    84.                 QualitySettings.currentLevel = QualityLevel.Fantastic;
    85.             }
    86.            
    87.             if(Input.GetKeyDown("escape")){
    88.                 showGraphicsDropDown = false;
    89.             }
    90.         }
    91.        
    92.         //Make quit game button
    93.         if (GUI.Button (Rect (Screen.width /2 - 100,Screen.height /2 + 50,250,50), "Quit Game")){
    94.             Application.Quit();
    95.         }
    96.     }
    97. }
    Thanks!
     
  16. Deleted User

    Deleted User

    Guest

    Thanks NukeOrama! glad you're enjoying the prefab! Oculus Rift support is something we're working on. We've had some early success using the OVRCameraController in a rough state. We don't have an Oculus Rift to test these changes on, so I don't know how it looks on the actual headset. In the editor it seems to be working. Here are the steps to at least be able to walk around and shoot weapons:

    -Select the FPS Camera and disable it by clicking the box in the upper left corner. Its children should get automatically deactivated too.

    -Drag the OVRCameraController prefab over the !!!FPS Main object so it becomes a child of that object (FPS Main)

    -Select the deactivated Main Camera object, click on the gear icon and copy the CameraKick component, and for both the CameraLeft and CameraRight children of the OVRCameraController, click on the gear symbol and select Paste Component As New to add the CameraKick component to the CameraLeft and CameraRight objects.

    -Select the deactivated Main Camera object again, click on the gear icon and copy the Animation component with the camera animations, and for both the CameraLeft and CameraRight children of the OVRCameraController, click on the gear symbol and select Paste Component As New to add the Animation component to the CameraLeft and CameraRight objects.

    -Select the deactivated FPS Camera object and copy the SmoothMouseLook component, then paste the SmoothMouseLook component as new on the FPS Weapons object.

    -Select the FPS Weapons object and deactivate the GunSway component

    -Select the FPS Weapons component and double click on the PlayerWeapons script to open it in MonoDevelop. Then comment out the HideInInspector statement before the cameraObj declaration like this:

    Code (csharp):
    1.     //[HideInInspector]
    2.     public GameObject cameraObj;
    -Select the FPS Weapons component, expand the OVRCameraController object in the Hierarchy window, and drag the CameraLeft object over the newly exposed Camera Obj field of the PlayerWeapons component in the inspector. This might make the weapon look offset to the left in the headset, ideally I'm guessing the weapon should be positioned halfway between both cameras...

    -Select the FPS Player component and double click on the FPSRigidBodyWalker script to open it in MonoDevelop. Then comment out the HideInInspector statement before the cameraObj declaration like this:

    Code (csharp):
    1.     //[HideInInspector]
    2.     public GameObject cameraObj;
    -Select the FPS Player component, and drag the FPS Weapons object from the Hierarchy window over the newly exposed Camera Obj field of the FPSRigidBodyWalker component in the inspector.

    -Select the OVRCameraController and drag the FPS Weapons object from the Hierarchy window over the Follow Orientation field of the OVRCameraController component

    -If you want the mouse just to rotate the view yaw, but not the pitch, do the same step as above, but drag FPS Player instead.

    -Select the set the near clip plane of OVRCameraController, CameraLeft, and CameraRight to 0.01f so the gun won't get clipped close to the camera.

    And unless I forgot something, you should be able to run the scene with no errors. Some things to note, the player will be dwarf sized. You can raise the y value of the Eye Center Position of the OVRCameraController component, but the weapon firing raycast stays at a lower position, resulting in inaccurate, low firing weapons. The weapons will also look like they are further forward than normal, which is due to the weapon camera being removed. The weaponName_anim objects can be moved towards the camera a bit or the camera FOV can be decreased to reduce this.

    So it's not perfect, but you'll have to try it out on the Oculus headset for the true test though. Ideally there would be more time to work on this, but we are really busy on the next updates for the prefab. Feel free to let us know if you run into problems following the steps above or if you have any more questions.


    Hi Dari, the bullet mark lifetime is located in the FadeOutDecals.cs script in the line:

    Code (csharp):
    1. if(startTime + 10 < Time.time){
    Just change "10" to however many seconds you want the decals to stay. This will be made editable from the inspector for the next version. Thanks!

    The bullet shell lifetime can be set by changing the Shell Duration var of the WeaponBehavior component attached to the weapon objects.


    Great! Glad that fixed it for you inglipX :)


    Thanks I'll check the inbox. Very sorry for the delay in getting back to you. Not my intention at all, just have been very busy :)


    In older versions the player used to sprint only when the sprint button was held, but we introduced the feature where you only have to tap the sprint button. This behavior should be updated to detect when the button is held instead of treating the button being held as a press. The zoom button already has this functionality so it will just be a matter of updating to the same method for the sprint button. Thanks for pointing this out.

    The weapons shake as you get further away from the scene origin (0,0,0) due to floating point precision loss. This could be minimized or at least delayed, by scaling up and repositioning the weapons so it will take longer for the shaking to be noticeable. The current weapons are a bit on the small side and are moved using smaller values because we had tried fitting them inside the player collider to prevent the guns from clipping into level geometry before we were using a weapon camera. We left them the size they are because we wanted to have to option to experiment with not using a weapon camera for testing.

    The easiest way around this with the current version is to spawn your player in a negative coordinate like -600 and have them move into positive coordinate values, but not exceeding the point where jittering starts to happen, usually around 1000 units from the origin with the current weapon scale. This allows about a 2000² area to work with, which is a decent size for most games. We hope to work out a better fix for this later using a technique like the ones discussed on this page and this page.
     
    Last edited by a moderator: Jun 7, 2013
  17. Deleted User

    Deleted User

    Guest

    Thanks Dari, you beat me to it!


    I don't recognize that script, but if you are using it with the Realistic FPS Prefab, you might want to check in the Update() loop of our SmoothMouseLook.cs script that the cursor isn't being hidden there when this script is trying to unhide it. You can add a reference to the above script in SmoothMouseLook.cs to check if the game is paused and bypass any code that looks like this:

    Code (csharp):
    1. Screen.showCursor = false;
    ...when the game is paused. Edit: I just looked at our script again and it shouldn't be hiding the cursor if the timescale is zero. So that must not be the issue.
     
    Last edited by a moderator: Jun 7, 2013
  18. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    No problem, thanks, I now have pause menu and options! :D
    By the way, I tried to fix drag problem when I build the scene, I changed public Update to private Update or however it says in your post, but still not working, is there anything more I gotta do?
     
  19. Deleted User

    Deleted User

    Guest

    Nice job on the pause menu. For the DragRigidbody.cs issue, you won't have to change the private or public keywords of any variables. Just to be clear, you can start by changing line 21 of DragRigidbody.cs if you haven't already from this:

    Code (csharp):
    1.     void FixedUpdate (){  
    to this:

    Code (csharp):
    1.     void Update (){
    You can also experiment with changing line 26 of DragRigidbody.cs which looks like this:

    Code (csharp):
    1.         if(!Input.GetKeyDown(FPSPlayerComponent.moveObject)){
    to this:

    Code (csharp):
    1.  
    2.         if(!Input.GetKey(FPSPlayerComponent.moveObject)){
    The object you're trying to drag should also be set to a layer that is included in the Layers To Drag mask of the DragRigidbody component. Let us know if you're still having problems.
     
  20. zeppeldep

    zeppeldep

    Joined:
    Jun 2, 2013
    Posts:
    27
    Hi There.. I am trying to discover how the foot steps sound is setup.
    Assets > Scripts > Camera > VerticalBob.cs has a variable: public AudioClip[] walkSounds;
    and plays the clip ..
    audio.clip = walkSounds[Random.Range(0, walkSounds.Length)];//Select a random footstep sound from walkSounds array
    audio.volume = 0.5f;
    audio.Play();

    but where is walkSounds defined? .. it's probably an AudioSource - yes?

    Thank you.. I am new to Unity3D, but I have years of c# development experience .. I have not attended the training yet, hoping for a chance.
    Thx for reading..
    Kevin.
     
    Last edited: Jun 8, 2013
  21. NukeOrama

    NukeOrama

    Joined:
    Jun 5, 2013
    Posts:
    3
    Hey Azuline. WOW! thank you so much for the step by step Oculus integration instructions, IT WORKED!! Needs a lot of tweaking but I am very excited by the results so far. I will post back all the additional changes I have made once it is all complete (may help speed up your Rift integration). One bit of feedback I can offer so far is that changing the Eye Center Position of the OVRCameraController component is a no-no. This is because the Eye Center Position is relative to the Neck Position, and increasing its Y value creates the effect of bending over forwards/backwards when looking up or down. Very disorienting. Rather than change the Y value of the Eye Center Position of the OVRCameraController (to remove the dwarf effect), I changed the Y value of the Neck Position. This works perfectly.

    Thus far; I raised the Y value of the Neck Position to 1.4, then I raised the Y value of the weaponName_anim objects to 0.9 and finally the "Weapon Zoom YPosition" in the Weapons "Weapon Behavior (Script)" to 0.26 and so far it all lines up nicely.

    The effect of aiming down the gun sights/iron sights was simply awesome. There is a focus issue that occurs when doing this, because there is a big discrepancy between the position of the rifle butt in the left and right camera, however this mirrors real life as holding a gun like that and trying to focus on the back portion of the rifle while it is so close to your face is exactly the same effect, thus I found myself naturally, and automatically closing one eye to peer down the iron sites. Very realistic, very immersive!

    Since getting my dev kit I have been intrigued as to how an FPS would "feel" in the Rift. I have tried a couple of the Oculus FPS demos and was not impressed by the way the gun behaved as though it was fixed to the side of your head and pointed wherever you looked. It just felt unrealistic and lazy. This feels much more natural when the gun is aimed independently of your view.

    Next I need to adjust the Scale of the weapon images, as currently they look like little toys when you equip them. That's easy even for a noob like me, but what I really need to do is change the way the guns move.

    It appears that the Weapon_Anim pivots relative to the "FPS Weapons" component Transform Position, specifically the Y position. Because I have raised the Weapon_Anim Y position it results in the gun arcing way forward of the player when mousing downward (I hope that makes sense, I am new to all this). I am a rank noob at C code, so can you tell me how I can edit the "Player Weapons (Script)" in the FPS Weapons component to add something like 1.2 to the Y position of the FPS Weapons object (Transform). In other words I am wanting to raise the height of the "FPS Weapons" component rather than the height of the Weapon_Anim. Does that sound right? Also hoping that in doing so it will raise the Y position of the origin of the tracer, (at the moment it appears to come from my knees), if not, how would I go about raising the Y position of the origin of the tracer?

    Thanks so much for your help, having heaps of fun with this.
     
    Last edited: Jun 8, 2013
  22. inglipX

    inglipX

    Joined:
    Aug 9, 2012
    Posts:
    30
    Hello Azuline,

    How can i make jumping have no delay. Currently if i jump once i need to wait about 2 seconds after i've landed to jump again. Im making a platformer so constant jumping is need. Thanks
     
  23. awesomeface

    awesomeface

    Joined:
    Jul 30, 2012
    Posts:
    9
    I haven't bought it yet and I don't know whether this question has been asked but if the player is seen by another, will only a gun and hands be shown or will the player be seen as a whole human, if not, will you make it so that they are seen as a whole human
     
    Last edited: Jun 9, 2013
  24. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    Only guns and hands.
    Azuline, yes, I'm still having problems with drag objects script, I tried what you said and didn't worked when I compile the game, thanks for your patience! Is the new version almost finished? :)
     
    Last edited: Jun 9, 2013
  25. zeppeldep

    zeppeldep

    Joined:
    Jun 2, 2013
    Posts:
    27
    oops my terms are probably incorrect here.. I can see that walkSounds is an array of audioclips .. I just cannot find the place where sounds are allocated to this field .. plse help .. thx .. Kevin..
     
  26. Deleted User

    Deleted User

    Guest

    Hi zeppeldep, the walkSounds are allocated to the array through the inspector. You can select the !!!FPS Main/FPS Player object and drag sound effects from the Project Library to the walkSounds array of the Vertical Bob component of the FPS Player Object. These kind of arrays in Unity are called builtin arrays. In the next version, the footstep code and sound effects will be in a separate script. Hope that answers your question.


    No problem NukeOrama, thanks for the tips and description of how the prefab looks in the headset! You mentioned that the weapon arcs forward when you look down. Is this a temporary movement before it returns to center, or does the weapon stay in the forward position? Also, do you notice this only when you have moved the weaponName_Anim mesh object upwards (increased the Y value) in the scene view or inspector, or do you notice it also if you have only changed the Weapon Unzoom/Zoom X/Y Position values of the weapon's WeaponBehavior script component?

    I'm also able to position the weapons closer to the camera by moving the weaponName_Anim mesh directly in the 3d scene view by dragging the blue arrow (z axis). There is no management of this axis of the weapon's position in the scripts, so it should be safe to change directly. To have the tracers and bullet origin aligned with the muzzle flash position, you can change the rayCast code in WeaponBehavior.cs around line 755 from this:

    Code (csharp):
    1.  
    2. if(Physics.Raycast(Camera.main.transform.position, direction, out hit, range, bulletMask)){
    to this:

    Code (csharp):
    1.  
    2. if(Physics.Raycast(muzzleFlash.transform.position, direction, out hit, range, bulletMask)){
    Glad you've had some success with the Oculus rift and the Realistic FPS Prefab! As you said, there is still some tweaks that need to be made, but a lot of the normal player and weapon behaviors seem to have transferred over to the OVRCameraController pretty well.


    Hi inglipX, you can try setting the Anti Bunny Hop Factor of the FPS Rigid Body Walker component attached to the FPS Player object to 0. The default is 0.35 to make there be a delay between the time allowed for jumps.


    Currently the player would only be seen as the first person weapon model from an external perspective. The first step to adding this feature would be a thirdperson mode. This would be a matter of updating the current scripts with thirdperson state checks and writing a new script to play the correct animations of the player model since all the movement and weapon methods have been established. After a thirdperson mode has been added, then there would need to be network code implemented to detect the clientID of the player and render the prefab in thirdperson mode if the clientID is not the player. A thirdperson mode is a possibility down the road. If you have any more questions awesomeface, please let us know.


    Ok sorry to hear that Dari. Can I ask some questions to understand the issue you're having? First of all, are you are using the default configuration of the prefab with the pause menu script you've implemented, or have you made any other changes to the scripts or prefab set up? Does your video card driver settings and project quality settings have VSync turned off, which means FPS is not limited and can be as high as your machine can render? Also, can you drag rigid bodies normally in the editor or windowed mode, but notice the problem only in full screen mode, or does the object dragging not work in the editor either? And the last question, have you noticed this problem only in version 1.16, or did you experience it in previous versions as well? Thanks.
     
    Last edited by a moderator: Jun 9, 2013
  27. drift501

    drift501

    Joined:
    Apr 20, 2012
    Posts:
    76
    Hello. In your pack I notice you have a shotgun. By looking at this it looks like the player loads the shells, pumps the gun and then can fire. Say that you have a shotgun with a capacity for 4 shells. In real life to load this gun you would insert 4 shells, pump the gun bringing one shell into the barrel and freeing up one space in the magazine. This way you shotgun with an ammo capacity of 4 is actualy holding 5 shells. Is this possible with this asset?
     
  28. sparky11520

    sparky11520

    Joined:
    May 24, 2013
    Posts:
    2
    I agree those would be great but vehicles should come in at some point and when they do I will buy this
     
  29. awesomeface

    awesomeface

    Joined:
    Jul 30, 2012
    Posts:
    9
    I thank you for answering my question, but when do you believe the feature will be available
     
  30. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    When there was the bug where you had to press on the screen twice with mouse so you can drag items in gameplay on Unity it worked fine when I compiled the game, now in the 1.16 version it won't work when I compile. Yes, I have enough good video card, 60 Hertz.
     
    Last edited: Jun 9, 2013
  31. zeppeldep

    zeppeldep

    Joined:
    Jun 2, 2013
    Posts:
    27
    Player motion sounds .. sorted : )

    THANKS AZULINE!!

    Azuline gave me the answer:
    the walkSounds are allocated to the array through the inspector. You can select the !!!FPS Main/FPS Player object and drag sound effects from the Project Library to the walkSounds array of the Vertical Bob component of the FPS Player Object. These kind of arrays in Unity are called builtin arrays.

    If anybody needs additional help for this same process, here is a capture of the values used in the scene:
    $fps-footsteps.PNG

    Azuline ROCKS! : )
     
  32. Deleted User

    Deleted User

    Guest

    Hi drift501, you're right about the shotgun loading method of the prefab. The maximum amount of shells are loaded, the gun is pumped, and then reloading is disabled until the ammo amount is less than the clip amount. The more realistic behavior you mentioned would be possible to add to the asset by modifying the default shotgun reloading method found in WeaponBehavior.cs.

    This would probably involve detecting if the player is at max ammo and not max ammo + 1, then reloading a single shell without pumping. If you wanted to add this behavior yourself we could give you some advice. We wanted to make the shotgun reloading for the asset use a pumping animation, but we haven't incorporated any chambered bullet or shell checks yet in our reloading code that would let the player add single chambered bullets or shells on-top of the clip amount. Hope that answers your question.


    Vehicles would be a nice addition! Once we get some more on-foot FPS features implemented we will look into this.


    No problem! The third person mode is probably a few updates away. From our developer's standpoint, it makes sense for us to implement some other features such as grenades and prone stance first to establish the weapon and player states. Once those behaviors are done, then it would be a good time to implement third person because there would need to be checks added to most of the scripts to determine if the player is in first person or third person mode. So it's not that we don't want to add the feature right away, it's just about trying to use our time efficiently and keeping the code base consistent. If you have any other questions, please let us know.


    Ok thanks for the info Dari! I just sent you a PM with the updated DragRigidbody.cs script that uses the new rayCast method only while in the editor. Hopefully it will solve the problem you're encountering in the full screen build.


    Thank you zeppeldep, if you like the footstep system in the current version, the new method we're using in the next version is even better :)
     
  33. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    I don't know why, but it is still not working when I compile it... Maybe it is because of the pause menu or when I changed show/lock cursor in SmoothMouseLook. It says no errors.
     
  34. NukeOrama

    NukeOrama

    Joined:
    Jun 5, 2013
    Posts:
    3

    The issue occurred in both instances; when the weaponName_Anim mesh object Y value was increased, and also when the Weapon Zoom Y Position was increased (i.e. values of the weapon's WeaponBehavior script component). The reason I had to increase these Y values was because I increased the Neck Y Value of the OVRCamera Controller (Script) in order to give the player more height (was too short otherwise), however since I am creating my own scene from scratch, I can easily scale the scene to suit the players "height" so I have set the Neck Y Value of the OVRCamera Controller (Script) back to 0 (default) and reduced all the WeaponName Anim mesh Y values and Weapon Unzoom/Zoom Y position values back to 0 (or whatever value lines up correctly with the players view) and so the weapons no longer stretch away from the camera when mousing down - problem solved for me.

    I adjusted the muzzle flash position's to fit the weapons and applied the script change as you posted, and bam! Its now perfect!. Everything is working fine in the Oculus Rift, and the effect is amazing. Seeing the tracer leave your weapon and hit the target is very.... satisfying... hard to put into words but its very cool. All that's left for me to do is to play around with the scale of the guns a little to get them to appear as the right size. Your a legend! thanks for your help. Will post back all the changes I made once I have got them spot on.
     
    Last edited: Jun 11, 2013
  35. Deleted User

    Deleted User

    Guest

    Hi Dari, do you remember if the object dragging feature was working before you added the pause menu script and made the changes to SmoothMouseLook.cs? You could test this by creating a new, empty project and importing the Realistic FPS Prefab with its default settings.

    If the new project without the pause menu does work, the problem must be with the code that was added. If it still doesn't work, I'll take a closer look at the script. If the problem goes away, then maybe there's something with the pause menu code that is preventing the raycast from hitting the objects in full screen mode.

    To answer your question from a few days ago (sorry I missed that) progress is going well on the new update. Just finished the water and swimming methods and now adding the limited sprint option. A new demo scene might be made to demonstrate the swimming feature as well.


    Great to hear about your success with the Oculus Rift, NukeOrama, that's really encouraging! Glad to hear you found a work-around too. The source of the weapon arcing issue is probably the fact that the PlayerWeapons and FPSRigidBodyWalker scripts have their Camera Obj references set to objects other than the camera. Which means that the origin for the weapon transform calculations is at a lower y value than when Camera Obj is set to the camera as it is by default.

    It might be possible to set the Camera Obj of the PlayerWeapons component to the CameraLeft object of the OVRCameraController prefab as well, but I haven't tried this myself yet. Thanks for your feedback!
     
  36. CactiiPie

    CactiiPie

    Joined:
    Jan 1, 2013
    Posts:
    12
    Hey Azuline I sent you a PM asking some questions about the Realistic FPS Prefab, I hope to hear from you soon! :cool:
     
  37. zeppeldep

    zeppeldep

    Joined:
    Jun 2, 2013
    Posts:
    27
    Hi There.. I would like to use the top left corner for more GUIText
    I could not find instances of GUIText in the scripts, although I did find .guiText 'properties' of Game Objects (or did I?)
    How did you draw the HUD text in this Project?
    Thx for your patience..
     
  38. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    Thanks Azuline, it seems that the pause menu script isn't right, it works with default scene.
     
  39. Deleted User

    Deleted User

    Guest

    Just sent you a reply PM, CactiiPie. Hope it helps with the features you were asking about!


    Hi zeppeldep, the GuiTexts in the Realistic FPS Prefab are rendered by components of instantiated game objects from the project library that are referenced by a var like "healthGuiObj" of the FPSPlayer.cs script. The reason you don't see a "healthGuiObj" field in the FPSPlayer component in the inspector view is that the GUIText object references have already been set and are hidden from the inspector using the "[HideInInspector]" statement. This is done to clean up the FPSPlayer script component in the inspector.

    If you look in the project library and navigate to !Realistic FPS Prefab Files/!Objects/!HUD you will see the GUI game objects/prefabs that are used to render the GUITexts and the crosshair. To make a new GUIText element in the upper left corner, you could duplicate the HealthText object, rename it, and change the vertical offset value of the HealthText component to 0.97 (the same vertical offset value of the HelpText object which is also rendered in the upper left corner). You can also make a new script by copying and modifying the HealthText.cs script and then attach it to your new game object/prefab that renders your new GUIText.

    To instantiate your new game object from the project library, you can add two new GameObject references to the top of FPSPlayer.cs like this:

    Code (csharp):
    1. [HideInInspector]
    2. public GameObject healthGuiObj;//this object is instantiated for heath display on hud
    3. [HideInInspector]
    4. public GameObject healthGuiObjInstance;
    5. public GameObject myNewTextGuiObj;
    6. [HideInInspector]
    7. public GameObject myNewTextGuiObjInstance;
    and then drag your GUItext game object from the project library over the myNewTextGuiObj field of the FPSPlayer component. To make the FPSPlayer script instantiate your new GameObject from the project library at runtime, add this code in the Start() function of FPSPlayer.cs:

    Code (csharp):
    1. myNewTextGuiObjInstance = Instantiate(myNewTextGuiObj,Vector3.zero,transform.rotation) as GameObject;    
    Note that the GameObject should always stay at the coordinates (0,0,0) to allow the GUIText to render in the correct position on the screen. These steps will get you started with your new GUIText, but there is still some more code that you would need to initialize the colors of the GUIText and the references to the variables in FPSPlayer.cs or other script that you want to display using the GUIText. Here's what some of the health text initialization code looks like in FPSPlayer.cs that you could copy and modify for your own GUIText:

    Code (csharp):
    1.  
    2.         //set reference for main color element of heath GUIText
    3.         HealthText HealthText = healthGuiObjInstance.GetComponent<HealthText>();
    4.         //set reference for shadow background color element of heath GUIText
    5.         //this object is a child of the main health GUIText object, so access it as an array
    6.         HealthText[] HealthText2 = healthGuiObjInstance.GetComponentsInChildren<HealthText>();
    7.        
    8.         //initialize health amounts on GUIText objects
    9.         HealthText.healthGui = hitPoints;
    10.         HealthText2[1].healthGui = hitPoints;
    Sorry if this sounds complicated, but hopefully this info will help you get started and give you an idea of where to look to duplicate our methods to make your own GUITexts. Please let us know if you have any more questions.


    I'll look at the pause menu script you posted again and see what might be interfering with the DragRigidbody script. You might want to make sure the object you have the pause menu script attached to is not assigned to the world collision layer. All of the GUIText rendering objects are instantiated separately from the prefab at runtime and are set to layer 14, the GUICamera layer so they are ignored by raycasts and rendered by the weapon camera, which has a higher depth than the main camera. Thanks for your patience Dari!
     
    Last edited by a moderator: Jun 13, 2013
  40. zeppeldep

    zeppeldep

    Joined:
    Jun 2, 2013
    Posts:
    27
    THANK YOU : ) you are fast becoming my 2nd Favourite human on planet Earth (after my wife) ...
     
  41. zeppeldep

    zeppeldep

    Joined:
    Jun 2, 2013
    Posts:
    27
    Hi Azuline, Where is the best place to return the object hit by the player?
    WeaponBehaviour.CS?
     
  42. inglipX

    inglipX

    Joined:
    Aug 9, 2012
    Posts:
    30
    how can i make the player taller?????? Hes sooo short... andwhen i item to make his capsule collider taller then he cant move anymore :(
     
  43. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    I am getting great use out of this. Managed to edit the code so he can spawn and find all the GO I got "null" errors. Got a "save game" working. Even swapped in a few new guns. Took me a little while to figure out the reload timing - except for some reason, it repeats the reload animation sometimes. I recall it happening with the guns you provided as well, so I don't think it is my additional guns specifically. In any case, how do I fix it so it only plays the reload animation once? I already have my clip set up to "once" but it still plays it up to three times.

    Thanks!

    edit: of course I just figured it out. duh. I hadn't set the bullets to reload to match the clip size. double duh.
     
    Last edited: Jun 15, 2013
  44. Deleted User

    Deleted User

    Guest

    Lol thanks :D Glad to help!

    Yes, WeaponBehavior.cs handles the weapon firing raycast. Around line 748 is the HitObject function which is used to apply forces, inflict damage, and play impact effects for the object or point hit by the raycast. The "hit" argument of the HitObject function is the RaycastHit of the weapon rayCast. So you could find the gameObject that was hit with "hit.collider.gameObject" or the rigidbody of the hit object with "hit.rigidbody" or the position of the weapon hit with "hit.point" in the HitObject function. Here is a blog post about how NPC and player damage is applied. Hope that answers your question zeppeldep.


    Hi inglipX, in version 1.16, scaling up the FPS Prefab object in the editor won't work to make the player taller because the player's capsule can be scaled up, but the scripts will think the player is always airborne due to the ground detection rayCast heights not scaling along with the collider height.

    If you need this feature right away, you could modify the crouching code and grounded checks in FPSRigidbodyWalker.cs to scale up with the player capsule collider height. This will be a lot easier in next update because increasing the player height will just be a matter of changing the Player Height Mod value of the FPSRigidbodyWalker component to something like 1.0 to add one unit of height to the player object. This will also scale up the collider's radius proportionately as well. Hope the wait won't be too much of an inconvenience.


    Nice job figuring that out drewradley! The behavior you mentioned with the weapon animation repeating during reload is actually an intended feature. For weapons like shotguns or bolt-action rifles, you have the option to load one or a few shells at a time instead of loading them all at once as is done with a magazine. If you have any other questions please let us know!


    As far as progress on the update, it is close to being finished. We've pushed the release back a bit by maybe a week or so, but for good reason. There's been discussion in this thread of an issue we are aware of that deals with weapons jittering the farther the player moves from the scene origin. We've looked into this and a solution has been implemented in our current build! So it's going to take a few extra days to test and resolve any issues. We are really excited about this because it will increase the maximum size of a scene that can be used with the Realistic FPS Prefab dramatically. Good news :)
     
    Last edited by a moderator: Jun 15, 2013
  45. zeppeldep

    zeppeldep

    Joined:
    Jun 2, 2013
    Posts:
    27
    Shadow GUIText?
    now a simple question.. (I hope)
    I have added GUIText objects and they are working correctly (thanks to your excellent, in depth replies).
    But.. My new GUIText objects dont have that lovely shadow effect that yours have.. Can you pinpoint what I could have missed?
    Thx ..
     
  46. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    Create new text and move it a bit down and a bit right and make it black color. (shadow text should be close to original one, just as I said)
     
  47. zeppeldep

    zeppeldep

    Joined:
    Jun 2, 2013
    Posts:
    27
    ? I see the duplicate object in the Hierarchy when running the game (see below). But where do I access/view the duplicates providing the shadows when editing?

    $shadowtext.PNG
     
  48. Deleted User

    Deleted User

    Guest

    Hey guys, the nameText(clone) objects you see in the Hierarchy window when running the scene are the objects that are instantiated from the project library in the Assets\!Realistic FPS Prefab Files\!Objects\HUD folder. The best way to add your own GUITexts would be to navigate to this folder in the Project Library window, then select one of the objects like HelpText, then right click on that object and select the "Show In Explorer" option. A window should pop up showing the folder containing these objects with the .prefab extension. You can copy one of these files in your OS's folder view and rename it. When you go back into Unity, your new object should show up in the HUD folder now.

    You then can select the MyNameText object in the Project Library window, and click on the right facing triangle next to it to expand the hierarchy and show the child object of the main MyNameText object you just created. The child object is what renders the shadow text with slightly different offset values than the parent object, which renders the top text with the non-shadow color.

    Looking at the screenshot you posted zeppeldep, it seems you've instantiated your own GUITexts, great job! You would just need to instantiate your new object in the same way and make sure when accessing the GUIText via script, to initialize and update the text of both the main and shadow objects like this:

    Code (csharp):
    1.  
    2.         //set reference for main color element of heath GUIText
    3.         HealthText HealthText = healthGuiObjInstance.GetComponent<HealthText>();
    4.         //set reference for shadow background color element of heath GUIText
    5.         //this object is a child of the main health GUIText object, so access it as an array
    6.         HealthText[] HealthText2 = healthGuiObjInstance.GetComponentsInChildren<HealthText>();
    7.        
    8.         //initialize health amounts on GUIText objects
    9.         HealthText.healthGui = hitPoints;//the main/top color GUIText
    10.         HealthText2[1].healthGui = hitPoints;//the shadow/bottom color GUIText
    You can swap out the HealthText references above for the name of your new script attached to your text object. The top two lines of code (not counting the comments) are for initializing the HealthText references and would be in the Start() function of a script. The bottom two lines are used here to initialize the healthGui value in the HealthText script, but can also be used in the Update() loop or other function to modify the variables of the HealthText.cs components of the instantiated GUIText objects. Hope that makes sense. Also, sorry if there is any delay in my responses, just have been busy working on the new update.
     
    Last edited by a moderator: Jun 17, 2013
  49. zeppeldep

    zeppeldep

    Joined:
    Jun 2, 2013
    Posts:
    27
    doh! ... I wondered what that small triangle was for .. when I clicked on it last week I saw a second object ... I thought I was making a mistake by creating an unwanted duplicate ... now it makes sense.. the triangle exposes the copy ... ... yet again .. Thx Azuline

    What is the best way to add background music?
    I can easily add a audio source to the camera. But If I did that how would the player be able to switch it off?
    When I play games I immediately mute the music, preferring my brand of noise. But A game is not a game if it does not have music (that can be switched off).

    Thx again ..
     
  50. inglipX

    inglipX

    Joined:
    Aug 9, 2012
    Posts:
    30
    q1 Hey Azuline, you know how when you press shift your players camera zooms out a bit as u sprint and then returns upon stopping? I am trying to disable the zooming out when my player is underwater (below a certain y position) because underwater u cant sprint.. What script controls this?

    **Additional Question2: i try to make my scene dark and i remove all lights, set ambient light color to pitch black, but when i go into the game with the fps prefab player the floor is still lit....In the scene view it is pitch black but as rendered from the main cam it isnt. What's wrong???

    **Question 1 I've figured it out. But now as i continue to perfect my water movement i realize i must change all these variables of headbobbing and stuff, unless i can disable sprinting? You should definitely implement swimming in the next update...im a Javascript programmer so i cant modify the scripts :(
     
    Last edited: Jun 18, 2013