Search Unity

Realistic FPS Prefab [RELEASED]

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

  1. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    No problem zeppeldep! I agree that music is hugely important to a game. The only reason there's no music currently used in the asset is that we wanted to emphasize the sound effects of the player actions (like the landing sounds, footsteps, weapon sounds, ect.) to help demonstrate the features of the Realistic FPS Prefab.

    When adding your own music, you can chose to have it play at the same volume throughout the scene, or you could play the music audio clip from a 3D audio source that gets louder or quieter depending on player distance. For the first option, you could add the music audio clip to the Project Library and in its import options, uncheck the "3D Sound" box to make the sound play at the same volume throughout the scene. Then to play the sound, you could attach an Audio Source component to the FPS Camera object, set the Audio Clip field to your music file, and make sure the "Play On Awake" and "Loop" boxes are checked to have the music play when starting a scene.

    To have the music play at a particular point in the scene, you can keep the "3D Sound" box of the music effect's import settings checked to have the music fade in and out the closer the player gets to the audio source. Then you could create an empty game object by clicking on the GameObject menu and selecting "Create Empty". Then create an Audio Source on the new game object with the same settings as the 2D music Audio Source mentioned above. You can then position the new Game Object anywhere in the scene to hear the music when the player is within the Audio Source's range. That should at least get you started with playing music in your scenes.


    Hi inglipX, you said you figured it out, but to answer your first question the camera's FOV value and bobbing amounts are set in the Ironsights.cs script, which handles most of the weapon positioning and camera effect changes based on the current player state like idle, walking, zooming, sprinting, or crouching.

    The next update does include swimming and all of the changes you mentioned have been addressed. All you will have to do is position a water zone prefab in your scene and the new scripts will handle everything else. By default the player won't be able to sprint in water and there will be no visible effect of pressing the sprint button while swimming. If you want to experiment with disabling sprinting for your current project, you can set the cancelSprint var of FPSRigidBodyWalker.cs script to true when your player is in water, which is what we have done in the new update.

    For your second question about the floor still being lit, you might want to check that the floor object Mesh Renderer component is using a shader that is not from the "Self-Illumin" group. You also can go to Window->Lightmapping and then in the Lightmapping window click on the Clear button to remove any lightmaps for the scene. Note that you will have to bake the lightmaps again if you want to reverse that decision. It may be better to uncheck the "Use Lightmaps" box in the Lightmap Display window that appears over the 3D scene view when the Lightmapping window is visible to avoid having to bake the lightmaps again if that is not the issue. Not sure what else could be causing the floor to still be lit if all lights are also disabled, but hopefully one of the two suggestions above will work for you.
     
    Last edited: Jun 18, 2013
  2. roxasguy

    roxasguy

    Joined:
    Nov 19, 2012
    Posts:
    10
    Hi, I have a problem. I'm setting up my weapons, but they keep, "Malfunctioning". The "Fire" animation doesn't get played when the gun fires! Everything else works but this! Some weapons I make DO play the animation, while others do not. Does anyone know how to fix this? Am I setting something up wrong? Thanks!
     
  3. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Hi roxasguy, sorry that you've run into issues with the firing animation of your weapons. I'd like to ask a few questions to get more information about what is happening to prevent the firing animations from playing. First of all, are the firing animations not playing for the default weapons as well, or are they not working for just the new weapons you've created? If the issue is not with the default weapons and only with the ones you've created, are you making the weapons using your own meshes from scratch, or are you attempting to duplicate an existing weapon while following the steps in this video?



    When you fire the weapon in the running scene, does the weapon fire and hit objects, but the firing animation does not play, or does the firing animation not play and the weapon also does not shoot and hit objects? The first scenario would indicate an animation setup issue, and the second would mean the weapon component or something else is misconfigured.

    The first thing you should check is that the Animation component of the MyWeapon_Anim mesh object under the MyWeapon object (which is a child of FPS Weapons) has the Fire, Reload, and Ready animations set from the same mesh in the Project Library window. This is done by expanding the MyWeapon_Anim object in the Project Library and dragging the Fire, Reload, and Ready animations to the Animations array in the Animation component of the MyWeapon_Anim mesh in the Hierarchy view.

    If the correct animations are linked from the original weapon mesh to the MyWeapon_Anim object in the Hierarchy view, another thing to check is that the Fire, Reload, and Ready animations are set up in the Animation Import Settings of the mesh. The start and end keyframe ranges should be set to the ranges for the animations in your imported weapon mesh. The wrap mode for the Reload and Ready animations should be set to Once and the wrap mode for the Fire animation should be set to Clamp Forever. Also, if you are using Unity 4, you'll want to make sure that the MyName_Anim Import Settings->Rig->Animation Type is set to Legacy.

    If all the above steps have been followed and you are still encountering the issue, the Weapon Behavior component of the weapon object might be configured incorrectly. You'll want to check that the Fire Anim Speed var of the Weapon Behavior component is set to a value greater than zero. If the weapon is not firing as well as not playing the animation, please verify that the Projectile Count and Bullets Per Clip vars are set to values greater than zero.

    Hopefully the above information will help, but if you are still encountering the firing animation issue, could you please provide some more information about what happens when you try to fire the weapon, such as, does the weapon fire bullets but not play the firing animation, are there any errors that occur when firing, or are there any unexpected movements of the weapon when firing that look like the animation has attempted to play but has been interrupted somehow? Thanks for your patience, roxasguy.
     
  4. Eyehawk

    Eyehawk

    Joined:
    Dec 24, 2012
    Posts:
    273
    Hi Azuline,
    I've just bought this from the asset store, and I'm highly impressed at how much you've packed into the kit! Great work! :p

    I was just wondering if there is a guide that could explain how I could swap other models with the default robots currently? I'm sort of at an noob to low intermediate skill level with Unity currently.
     
  5. Claymore

    Claymore

    Joined:
    Oct 17, 2012
    Posts:
    158
    Hi guys,just awesome project,you should add advanced main menu,but what can i say is after the new update,im gonna immediately buy this. :cool:
     
  6. inglipX

    inglipX

    Joined:
    Aug 9, 2012
    Posts:
    30
    Thank you Azuline
     
  7. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Hi Eyehawk, thank you! There is a lot more planned to be added to the asset as well. To answer your question, we don't have a guide up yet about how to swap character models, but we might make a guide once our zombie model has been animated. I actually spent some time importing and rigging a new character today, so I can explain some of the steps.

    The first thing you can do to use a new character model with the Realistic FPS Prefab, is to duplicate the existing robot prefab in the Hierarchy window and go to the GameObject->Break Prefab Instance menu to unlink it from the robot prefab in the library. Then rename the robot object to the name of your character and if you have the character mesh imported into the Project Library, drag that character mesh over the new character object in the Hierarchy window that was previously named "robot" so it becomes a child of the new object.

    You can then delete the other objects/meshes under the MyNewCharacter object except the character model you just imported. For the animations of your character to work with the AI scripts, the model should have animations set up in the animation import settings named idle, walk, run, and shoot. Then you can drag your character's animations to the Animations array of the Animation Component of the main/root character object. If your character has a separate ragdoll set up, you can drag it from the Project Library to the "Dead Replacement" field of the Character Damage component to have the ragdoll spawn into the world when the character dies. If you don't have a ragdoll, you can still use the dead replacement, but you just need to use another instance of the character model mesh that plays the "die" animation of your character model automatically by checking the Play Automatically box of the dead replacement's Animation component, making sure that the die animation is also the active animation in the Animation field of the Animation Component. You might also have to do some alignment of the objects and tweak the parameters of the character controller a bit.

    To set up a ragdoll for a new character, you can either use the Ragdoll Wizard (if your model has the required bone setup) or you can create Character Joints and colliders in the model's hierarchy to let it be moved by the physics system at runtime. You can add the base/root joint at the first/root bone of your character's Hierarchy and work from there, setting the Connected Body property to the bone that comes before it in the hierarchy.

    Setting up your own ragdolls can take some trial and error, but the end result it worth it. I might have missed a few minor things, but hopefully this will help get you started and give you some ideas until we write a guide. Please let us know if you have any more questions.


    Thanks Claymore! It's getting close. Just finalizing a few things and updating the documentation.


    You're welcome inglipX, glad to help.
     
    Last edited: Jun 20, 2013
  8. AgathaCrup

    AgathaCrup

    Joined:
    Jun 20, 2013
    Posts:
    22
    Hey Guys, $title.jpg
    Great to see you're rigging a zombie for your FPS, I've been in touch directly about this a few weeks ago ( rayopaz Opaz Multimedia) and it's a popular request on this thread. I bought a Zombie model ( Living Dead pack ) and have been trying to figure out how to do this ...made some progress but feel I need to learn more before asking dumb questions.

    But what I would like to ask is what model is it and when will you be releasing your next update?

    Keep up the great work.
    Warmest
    ray
     
  9. Eyehawk

    Eyehawk

    Joined:
    Dec 24, 2012
    Posts:
    273
    Hi Azuline,
    Many thanks for the details steps!

    I followed the instructions - I got to the part where I was to drag the animations into the animation array of the root character object (previously it was a copy of the Robot GameObject).

    When I ran the game, I noticed that while moving my new model wasn't animating, although it would still follow me.
    The console also showed a couple of errors:

    $rfps error1.png

    I tried with a couple of free models: one was Monster 2 (by BUMSTRUM) and the other one was the Spartan King one from the asset store.

    Did I have to use a model with a specific compatible animation type?


     
  10. AgathaCrup

    AgathaCrup

    Joined:
    Jun 20, 2013
    Posts:
    22

    Hey Eyehawk,

    That's as far as I got, I think the animations would need to have the same name, I haven't got round to it yet but i was going to try copying the relevant animations on my character and renaming them, then drop them back in the inspector then create a prefab and so on...if your character doesn't have relevant animations that's going to have to be sorted first
    ray
     
  11. Eyehawk

    Eyehawk

    Joined:
    Dec 24, 2012
    Posts:
    273
    Hey Agatha,
    Yeah I noticed that the prefabs of the Spartan King and Monster were quite different from the Robot ones, so wasn't entirely sure about their compatibility.
     
  12. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Hi ray, thanks! The zombie is a creative commons model that was released on the torque engine forums. Most of the animations are great, but the walking animation loop needs to be improved and then a ragdoll/character joints have to be rigged for it. No need to worry about asking questions, we all have to learn at some point! As for the next update, it looks to be about a week or so away. I know I said that two weeks ago, but I got wrapped up in solving the floating point precision issue and a few other fixes that ended up taking longer. As it stands now, it's mostly just down to creating a new demo scene, some testing, and updating the docs. Thanks again!


    Hey guys, I just spent some time working with the spartan king model and got it to work with the scripts. The problem was that the model had another layer in it's hierarchy above the actual meshes, so that when you imported the mesh to the scene, you would have the main parent/root mesh with an animation component that referred to the skeleton and meshes another level below it in the hierarchy. For some reason, making the spartan king root a child of a duplicated robot NPC object didn't allow the animations to be played by the scripts.

    The guide I wrote earlier was a best-case scenario where the mesh and skeleton are at the root level of the imported model. So to make the spartan king model's animations work, I had to add the AI scripts, character controller, and audio source to the root object of the spartan king mesh. Here is the prefab you can download that should carry over the changes I made if you imported the spartan king to the default Assets/SpartanKing folder.

    So I suppose the lesson to be learned is that ease-of-setup for new NPC meshes depends on how the model's hierarchy is configured and exported from the 3D modeling program. If the model imports into Unity with a root object with an animation component above the mesh rendering objects and skeleton, then the scripts, audio source, and character controller need to be added to that parent object. Sorry for the inconvenience. Also, the animation component might have all the correctly named animations (shoot, walk, run, idle [no caps]) but if the scripts give an error, you might want to re-drag over the animations from the Project Library to make sure they are the correct ones for the model. As for renaming animations, for the spartan king, I just had to rename "attack" to "shoot" and it worked. Hope this helps.
     
  13. Eyehawk

    Eyehawk

    Joined:
    Dec 24, 2012
    Posts:
    273
    Amazing! Thanks Azuline, it works perfectly :cool: I'll study the prefab to see how I can use other models too :p
     
  14. AgathaCrup

    AgathaCrup

    Joined:
    Jun 20, 2013
    Posts:
    22
    Hey Azuline, that's great news, do you have a link to the zombie model (didn't find it at Torque) just so I can take a look at it or throw up a screen shot.

    I do have a question for you, I'm making a mine field for the next game and currently have a box with a detonator script, parented to that is a box with your instant death script however I really wanted to have the instant death apply to the NPC's as well so if they step on a mine they get blown up too. Ideally I wanted it to have a proximity value for all characters within say 20 meters. The closest info I found was on the weapons behavior script but that's something of a minefield in itself, can you help?
     

    Attached Files:

  15. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    Well, just one curious question, when is the new update coming? You said that is almost finished, that's sounds great! :)
     
  16. AusAndrew19

    AusAndrew19

    Joined:
    Jun 6, 2012
    Posts:
    16
    I created my own pausemenu and if i use it i get this error.

    transform.localPosition assign attempt for '!Unarmed' is not valid. Input localPosition is { -0.023503, NaN, -0.003845 }.
    UnityEngine.Transform:set_localPosition(Vector3)

    My PauseMenu Uses Time.timeScale = 0; then reverts to Time.timeScale = 1; But when i resume game i get this error and then the weapons aren't showing correctly etc.
     
  17. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    Maybe it would be helpful if you put the script on forums so we can see what's the problem, and don't put it in FPS Weapons, create new, empty, gameobject and call it PauseMenu and put the script there.
     
  18. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    Hello, Azuline! I have one problem, when I drag object with "z" button, and then drop it with "x" button, it rotates very fast, I mean, it's like the force is too big, but its 500 as default. Rotate speed is insane, very fast, it's good on demo scene, I'm not sure what am I doing wrong, please help! :(
     
  19. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Great! Glad it worked for you, Eyehawk :)


    Sure, the model we're looking at is this one. We might change the texture a bit, but it's a nice, standard humanoid zombie.

    For the mine object, I was going to explain how to make one, but I ended up just writing a preliminary mine script and set up a mine prefab. You can download this package and import it into your project. There will be a new "Mine" object in the Assets\!Realistic FPS Prefab Files\!Objects\!InteractiveObjects folder than you can place in your scenes. There isn't an explosion effect yet and the explosion won't push surrounding rigidbodies, but the player and NPCs will be damaged if they enter the sphere trigger. There is also a cube that serves as a stand-in for a mine 3d model which can be shot to detonate the mine from a distance. The comments in the MineExplosion.cs script will also explain how the object works. Please let me know if you have any questions about it.


    Thanks Dari! Should be about a week or so to finish, depending on how long it takes to update the documentation. we'll definitely keep you guys posted.


    Hi AusAndrew19, did you notice this error when setting the timescale to zero with the asset's default setup, or has it started appearing after you created the pause menu? Version 1.16 should be able to pause by setting timescale to 0 without errors, so you might want to check that you have the most recent version of the prefab which adds if(Time.timeScale > 0){ checks at various locations in the scripts to allow pausing. If you do have version 1.16, could you please explain which object your pause menu script is attached to, what game objects or GUI elements it's attempting to modify, and perhaps post some examples of your pause script? Thank you for your patience.


    Hi Dari, do you know what the mass of the rigidbody is set to that you are trying to drag? If the mass is very small, you might want to try increasing it to 1 and then test the throwing feature. Also, you can try reducing the throwForce value at the top of the script. If none of those suggestions work, you can try changing this code of the DragRigidBody.cs script around line 94 from this:

    Code (csharp):
    1. springJoint.connectedBody.AddForceAtPosition((throwForceAmt * Camera.main.transform.forward), springJoint.transform.position);
    to this:

    Code (csharp):
    1. springJoint.connectedBody.AddForceAtPosition((throwForceAmt * Camera.main.transform.forward), springJoint.transform.position, ForceMode.Impulse);
    And then decrease the throwForce value at the top of the script to 7.0f. This will be a permanent change to the script because the default ForceMode of the AddForceAtPosition function is ForceMode.Force, which is intended to be applied over several frames where ForceMode.Impulse is intended to apply a force during a single frame or fixed timestep.
     
    Last edited: Jun 22, 2013
  20. AusAndrew19

    AusAndrew19

    Joined:
    Jun 6, 2012
    Posts:
    16
    function Update () {
    if (Input.GetKeyDown("escape")){ //Have We Pressed The Escape Key "Assigned To Pausing The Game"
    Time.timeScale = 0; //Sets Time Scale To "0" To Achieve The Effect Of A PauseMenu
    isPaused = true; //This Makes The PauseMenu GUI Show.
    }
    }

    //This Function Holds All The GUI Elements.
    function OnGUI(){
    GUI.skin = pauseMenuSkin; //Assigns The Custom GUI Skin So You Can Create Your Own Look
    if(isPaused)
    {
    //Continues Game.
    if (GUI.Button (new Rect((Screen.width / 2.05) - 50, (Screen.height / 2) - 60, 125, 40),"Resume"))
    {
    isPaused = false;
    Time.timeScale = 1;
    }
    //Takes You To The Options Menu.
    if (GUI.Button (new Rect((Screen.width / 2.05) - 50, (Screen.height / 2) - 20, 125, 40),"Options"))
    {
    //Disables MainMenu GUI And Enables Options GUI.
    isPaused = false;
    isOptions = true;
    }
    //Takes You To The QuitGame Menu
    if (GUI.Button (new Rect((Screen.width / 2.05) - 50, (Screen.height / 2) - -20, 125, 40),"Quit Game"))
    {
    //Disables PauseMenu GUI And Enables About GUI.
    isPaused = false;
    isQuit = true;
    }

    }

    I have version 1.16

    If i set the timeScale to 0 in project settings then back to 1 there is no issue. I Can't post my whole pauseMenu Script because i am modifying to add to assetstore, BTW, The pausemenu is attached to the MainCamera.

    This is what the error is pointing at.
    //apply temporary vector to gun's transform position
    gun.transform.localPosition = tempGunPos;

    I tryed creating empty gameobject attach the script to that same thing.
     
    Last edited: Jun 22, 2013
  21. AgathaCrup

    AgathaCrup

    Joined:
    Jun 20, 2013
    Posts:
    22
    Hey guys, working on a Saturday I'm impressed.
    Mine prefab works great, will there be a variable on the final script to allow different explosion prefabs, there are some cool ones in Ben Throops free detonator project ( https://www.assetstore.unity3d.com/#/content/1) which I was using?

    Thanks also for showing us the Zombie you're incorporating into the NPC library, just what I was looking for. I had already created a driver level for the next issue of my comic but its a bit of a fudge as the story really needed a zombie level so I can't tell you how anxious I am that you get the updates out in the next week or so as It would be better for me to have Zombies running around a prison, your eagerly awaited waypoint updates will be very helpful too. All the best.
    ray
     

    Attached Files:

  22. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    That information is very helpful, AusAndrew19. We only tested the pause functionality by setting the timescale to zero in the project settings. Just set the timescale to zero via script and saw the error you described. To fix this, you can modify the Gunsway.cs script and Ironsights.cs scripts. Near the top of those scripts is this check:

    Code (csharp):
    1. if(Time.timeScale > 0){//allow pausing by setting timescale to 0
    that should be changed to this:

    Code (csharp):
    1.  
    2. if(Time.timeScale > 0  Time.deltaTime > 0){//allow pausing by setting timescale to 0
    And the errors shouldn't show up anymore. Thank you for bringing this to our attention.

    Edit: Also discovered that this check needs to be added around the Update() actions of HorizontalBob.cs, CameraKick.cs, and VerticalBob.cs to prevent errors if pausing/unpausing while the player is moving. Sorry for the inconvenience. We just started to add these checks after we've been getting requests for the pausing functionality. All the fixes will be available in the next update in the form of a pause button as well. Thanks for bearing with us while we get this worked out.


    Of course :) thanks for the link. There will definitely be an option to use your own explosion effects since we have custom particle effect code implemented for weapon impacts as well. Your comics are coming along great!
     
    Last edited: Jun 23, 2013
  23. AgathaCrup

    AgathaCrup

    Joined:
    Jun 20, 2013
    Posts:
    22
    That's great Azuline, Thanks for the compliment. I am talking to investors at the moment and I have to say that without your prefabs my chances of getting funding would be a lil' slimmer a comic with game interaction is far more appetizing...respect due...Marvel watch this space :)
     

    Attached Files:

  24. inglipX

    inglipX

    Joined:
    Aug 9, 2012
    Posts:
    30
    hey Azuline! is there any way you can convert the FPSRigidbodyWalker.cs into a javascript? I really need to modify it a bit for my game and i want to be able to understand it ! Thank you
     
  25. AusAndrew19

    AusAndrew19

    Joined:
    Jun 6, 2012
    Posts:
    16
    @Azuline Studios, I really appreciate the time you took you reply. I can confirm once changing
    if(Time.timeScale > 0){
    to
    if(Time.timeScale > 0 Time.deltaTime > 0){

    This has successfully fixed my issue i have even tested running around be a loony and pausing in weird times. Not even a budge, Brilliant. Thanks for your top notch support :)
     
  26. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,061
    What's the best way to prevent a gun from zooming? I have added some large machine guns that I don't want the player to be able to zoom. Right now I simply set the zoom settings to match the non-zoomed. Problem is the cross-hair is gone this way. I know i can go into the code and do it that way, just wondering if there is a way to do it without that.

    Thanks!

    edit: I added a simple bool to check if the weapon can be zoomed or not. At this point, my biggest concerns are updates. I have edited the included code quite a bit and stupid me didn't bother to keep track of all the changes I made so I can redo them after updates. Perhaps you can include a document with what code is changed and what the changes are so I can make them myself? I mean for simple updates that only changes one or two lines. Either way, I guess I should go through and start a log of my changes.
     
    Last edited: Jun 24, 2013
  27. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Nice, a comic with an integrated game experience sounds like an original idea with some potential!


    Hi inglipX, we'll send you a PM with the script converted to JS, but there are some inter-dependencies between the FPSRigidbodyWalker script and the FPSPlayer and SmoothMouselook scripts that had to be resolved by removing/commenting-out or changing the dependent code in FPSRigidbodyWalker (mostly code involving player hit points, zooming states, and player input). We modified the converted script so it won't cause any errors, but it won't move a rigidbody as the C# version does. Once we have some time we might look into making this script work better, but we are focused on completing the next update at the moment. Sorry about that. Hopefully the script we sent you will at least give you some ideas and help you understand the C# version better. If you have any more questions, please let us know.


    Great, glad that worked for you, AusAndrew19!


    Good job on figuring that out drewradley! We'll add this feature to the new version too. What we did was add a new bool to WeaponBehavior.cs called canZoom and changed this code around line 207 of FPSPlayer.cs:

    Code (csharp):
    1. if(Input.GetKey (zoom)){
    to this:

    Code (csharp):
    1. if(Input.GetKey (zoom)  WeaponBehaviorComponent.canZoom){
    Which will allow you disable zooming per-weapon. As far as keeping track of your changes, that is definitely a good idea. Most of the scripts in new update have been changed to some degree, so it is advisable to back up your current project and UnityPackage of version 1.16 of the Realistic FPS Prefab so you can fall-back on the previous version as needed for testing in new projects. If you overwrite the 1.16 package, we can send send it to you as well. Once released, the change notes for the new version will give you an idea of what has been updated. Also you can run two projects side by side of the previous version and the new version and compare the scripts using WinMerge or Notepad++ with the Compare plugin to see exactly where the changes have been made. You can also create a new project and import version 1.16 and compare those scripts with your modified scripts to see where you've made changes. Sorry for the inconvenience, but we'll be available to answer any specific questions and give advice as needed.
     
  28. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,061
    That is exactly what I did. Even used same bool name. :)



    I figured it would be pretty extensive. I'll manage. Those are some good suggestions. I definitely plan to backup my project before importing. Learned my lesson on that one! And from now on, I'll work with notepad open so I can track my changes!

    edit: Also, sometimes zoom got stuck on and I just figured out that if you release the mouse button BEFORE the zoom finishes zooming in, it locks on. Perhaps that is intentional behavior?
     
    Last edited: Jun 25, 2013
  29. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Nice! Tracking your changes sounds like a good idea.

    By default the zoom function toggles if you tap the zoom button (sights stay up after releasing zoom button) and if you hold the zoom button to bring up the sights, when you release the button, the sights will lower. This is how some FPS games handle ironsights and we thought it gives the player the best of both worlds (toggled and held ironsights), but maybe we will make this behavior optional. Thanks for the feedback!
     
  30. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    Oh, I almost forgot to reply the post about DragRigidbody, I fixed it, I mean, I re-imported the asset :D
     
  31. Grespon

    Grespon

    Joined:
    Apr 13, 2012
    Posts:
    387
    Hi.
    I have Ultimate FPS Camera. It's great. But unfortunately it's based on the unity's Character Controller, which makes impossible to achieve what i want:

    - the player to be able to walk on a small planet like Mario Galaxy. Is it possible/easy with you asset ??

    Thanks!
     
  32. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,061
    So I've encountered another problem you may or may not be aware of; the camera often gets really jittery when I switch/ready weapons. I remember reading that it gets jittery if you move too far from the base or something like that but this happens when I haven't even moved. I can stop it by switching or holstering and drawing weapons - reloading also seems to stop it. Any thoughts on where to begin looking for what could cause this?
     
  33. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Glad to hear that, Dari! maybe your project was using the old version of the script or the Layers to Drag mask was reset.


    Hi Grespon, that depends on how you want to implement spherical movement and the requirements of your project. If you don't need to modify the world much, then either the Ultimate FPS Camera or the Realistic FPS Prefab could work by rotating the spherical world around the player, while the player object/controller remains stationary and oriented to an absolute direction like Vector3.up, as discussed here.

    If you need to implement your own spherical coordinate/movement system, the player rigidbody used in the Realistic FPS Prefab could be set to Is Kinematic and moved via script instead of the physics system. Then the player's velocity direction can be modified to be perpendicular to the player position->planet center direction, which would also be the direction that you could apply gravity to the player in our rigidbody character controller script.

    I've not actually tried doing this, so it might be a good idea to do some experiments/prototyping to find out which approach you want to use. There is more discussion on this topic here, here, here, and here. Feel free to contact us again if you have any more questions.


    Have you tried implementing this fix, drewradley? There is an issue in version 1.16 where the camera animation values might not return to zero, causing jittering of the camera and weapon after a weapon switch. This will be fixed in the new version. I hope this will resolve the issue for you, but please let us know if the jittering is still occurring after applying the fix and we can give you some more suggestions.
     
    Last edited: Jun 29, 2013
  34. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,061
    Thanks! I've made these changes and it seems to have fixed it. At least in my tests right now.
     
  35. inglipX

    inglipX

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

    I have been trying to make a parkour- mirrors edge style game and I need help with making climbable walls. If i jump off one rooftop to reach another but miss the other rooftop by a small amount i want my player to grip o and be able to vault up. How can i do this?

    These are ladder triggers
    When player hits the small one it latches on and I can move side to side and up. When I go around the edge I want to grab the next ladder trigger. Unfortunately the player doesn’t grab it and falls


    $img1.png

    Thanks
     
    Last edited: Jun 30, 2013
  36. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    627
    With what exists currently, you could possibly simulate the effect you want by setting ladder triggers up around the edges of rooftops. The idea is that if the player jumps across but barely misses the rooftop, the player's collision would be 'caught' by the ladder triggers like a net, and propelled up and onto the rooftop like a trampoline.

    This would require a modified ladder script, however, who's purpose is purely just to 'catch' the player, hold them mid-air for half a second, then boost them up and slightly forward (air control) to give the effect of vaulting up on to the roof.

    Though, this is purely for functionality. Without any custom hand animations of grabbing onto the building and pulling yourself up, all work is delegated to how the player's camera is animated, and even then you'll likely find it lacking. But if you can live without the animations, something along the lines of what I wrote above could possibly work.


     
  37. inglipX

    inglipX

    Joined:
    Aug 9, 2012
    Posts:
    30
    These are ladder triggers
    When player hits the small one it latches on and I can move side to side and up. When I go around the edge I want to grab the next ladder trigger. Unfortunately the player doesn't grab it and falls

    View attachment 58558
     
  38. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    627
    Trigger-based ladders typically need the player to be facing it to work, which is likely why you're able to grab the first ladder trigger, but not the second one, which faces a different direction. Can't really think of a way to do it without custom code, so hopefully Azuline can help you.

    Good luck!


     
  39. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Great! If you run into any other issues, please let us know so we can address them.


    Hey guys, to answer inglipX's first question with the overlapping ladder triggers making the player fall, this is a quick fix. You'll just have to comment out this line in the ClimbLadder function of Ladder.cs:

    Code (csharp):
    1. //triggerState = true;
    The triggerState var was used to only set the climbing bool of FPSRigidBodyWalker once when entering the trigger. This was done for efficiency and to try to be more friendly with the physics system, since it usually likes parameters to be changed once and to not be set every frame/fixedTimestep, but setting the climbable var to true every frame/fixedTimestep doesn't seem to be causing any problems and allows the player to use adjacent triggers to climb around corners.

    By commenting out the line above, the climbable var will always be set to true when the player is in the ladder trigger, so when they move to a different trigger, they won't fall because climbable had already been set to true, prior to entering the next trigger. You'll also want to make sure when placing the triggers around corners that there isn't too much of a gap so the player has some space to maneuver around the corner.

    To answer your second question, here's two scripts that can add basic ledge vaulting. The first one is called VaultTrigger.cs and can be attached to a collider near the edge you want the player to vault. When the player enters the trigger with a VaultTrigger.cs component, an upward force will be applied to the player's rigidbody and they will be able to climb the ledge if they are pressing the move forward key. Like lod3 said, this method could be improved by not requiring the player to hold forward to jump the ledge and by playing climbing hand and camera animations and sound effects.

    VaultTrigger.cs also disables its trigger after the player has exited it to prevent the player from falling back down on the vault ledge trigger and hovering. The second script called VaultTriggerActivate.cs is placed on a second trigger on the floor or accross a gap that re-activates the original vault trigger when the player is in position so the player can vault up it again. This method could also be improved or automated somehow, but using these two triggers in unison seems to be simple and gives the level designer control over what ledges can be vaulted and when the vault triggers become usable.

    Here are the scripts:

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. //allows the player to pull themselves up over ledges
    4. public class VaultTrigger : MonoBehaviour {
    5.     public float upwardPullForce = 0.3f;//force that pulls the player upwards when they enter the vault trigger when jumping
    6.     private GameObject playerObj;
    7.    
    8.     void Start (){
    9.         playerObj = Camera.main.transform.GetComponent<CameraKick>().playerObj;
    10.     }
    11.    
    12.     void OnTriggerEnter ( Collider other  ){
    13.         //on start of a collision with vault trigger call VaultLedge function
    14.         VaultLedge(other);
    15.     }
    16.    
    17.     void OnTriggerStay( Collider other  ){
    18.         //on continued collision with vault trigger call VaultLedge function
    19.         VaultLedge(other);
    20.     }
    21.    
    22.     void VaultLedge ( Collider other ){
    23.         FPSRigidBodyWalker FPSWalkerComponent = playerObj.GetComponent<FPSRigidBodyWalker>();
    24.         if(other.gameObject.tag == "Player"){
    25.             //apply upward velocity to player rigidbody to vault ledge
    26.             playerObj.rigidbody.AddForce(new Vector3 (0, upwardPullForce, 0), ForceMode.VelocityChange);
    27.             //set grounded in FPSRigidBodyWalker to true to allow the player
    28.             //full air manipulation to move forward over ledge
    29.             FPSWalkerComponent.grounded = true;
    30.         }
    31.     }
    32.    
    33.     void OnTriggerExit( Collider other  ){
    34.         //on exit of vault trigger, deactivate trigger to prevent player from falling on it from above and hovering
    35.         if(other.gameObject.tag == "Player"){
    36.             transform.gameObject.GetComponent<BoxCollider>().enabled = false;    
    37.         }
    38.     }
    39. }
    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. //Reactivate Vault Triggers when player is in position to use them because
    4. //VaultTrigger.cs script deactivates its box collider/trigger to prevent
    5. //player from falling down on it and hovering upwards. This script can
    6. //be placed on the floor below the original Vault Trigger, or across a
    7. //gap that the player might jump over and vault up the opposite ledge
    8. public class VaultTriggerActivate : MonoBehaviour {
    9.     public BoxCollider triggerToActivate;//the box collider to reactivate (set in inspector by dragging trigger object over this field)
    10.    
    11.     void OnTriggerEnter ( Collider other  ){
    12.         //on start of a collision with this trigger, reactivate triggerToActivate collider
    13.         triggerToActivate.enabled = true;
    14.     }
    15. }

    And here's two examples of the trigger setup with the wide and narrow trigger being the one with VaultTriggerActivate.cs attached and the more cube-shaped trigger being the one with VaultTrigger.cs attached that will pull the player up the ledge. Also note that in version 1.16, the player still gets stuck when trying to jump against a wall they walked into. This will be fixed in the next version, but to test the vaulting feature, you'll probably not want to not run directly into the wall before vaulting and jump towards it from a small distance away. Hope this can at least get you started, inglipX.

    View attachment 58638
     

    Attached Files:

  40. inglipX

    inglipX

    Joined:
    Aug 9, 2012
    Posts:
    30
    Thank you very much Azuline! This has helped me out a lot. Thank you!
    However, commenting out the triggerstate doesn't fix that one issue....
     
    Last edited: Jul 1, 2013
  41. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Hi inglipX, do you still notice the issue in both the editor and the standalone? When the trigger state was uncommented I noticed the same thing with the player falling between ladder triggers, but on my setup I'm now able to climb around the corner. Is there any kind of gap between the triggers on the corner as all? The two triggers should take up the whole volume around the corner and can even overlap a bit. Here's a picture of how I set up the ladder triggers in my scene that allow the player to climb around the corner. If you're still having issues please let us know.

    $laddertriggerscorner.JPG

    Edit: You should also make sure that the trigger's box collider is set to Is Trigger and the ladder trigger object is set to layer 10 (world collision) or layer 0 (default). If Is Trigger isn't checked, it will seem like the player runs into an invisible wall and the trigger should also be set to layer 10 or 0 to tell the scripts to detect collisions between the player and the collider.
     
    Last edited: Jul 1, 2013
  42. inglipX

    inglipX

    Joined:
    Aug 9, 2012
    Posts:
    30
    I have it exactly like that expect the colliders are a bit thinner so the player doesnt float on top of them; but it still doesn't work. My triggers are only situated at the top of the wall because i don't want to be able to grab it at the bottom since your "hands" can't reach the top.

    image : http://imgur.com/iRbZEPa
     

    Attached Files:

    Last edited: Jul 1, 2013
  43. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    Hello Azuline, I have one question, maybe it's a bit too much, but I don't have any idea of making this works: I have AI (Robot) following me, he doesn't shoots at me, I put the shoot range to 0. Now, what I want is (that complicated part :/) when the Robot come close to the other AI which isn't him and isn't marked as Robot, he stops and keep shooting him like he would shoot me if I would put shoot range to positive number, that means it deals damage to the other AI and can kill it. (Of course when he kills it, he starts to follow me again) Sounds pretty much and hard, I don't know... If you don't have time, maybe you can just lead me into the right way of making it, thanks in advance! :)
     
  44. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Ok, that all looks good, inglipX. I think the problem is that I am running a newer ladder script than 1.16. The new script also checks OnTriggerStay where the old script just checks OnTriggerEnter. Sorry about that. You can try changing this line of ladder.cs:

    Code (csharp):
    1. void OnTriggerEnter ( Collider other  ){
    to this:

    Code (csharp):
    1. void OnTriggerStay ( Collider other  ){
    and also keep the triggerState = true; line commented out. The player should be able to switch ladder triggers in mid-air now, but if you have any more questions about this, please let us know.
     
    Last edited: Jul 2, 2013
  45. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Hi Dari, that sounds like a neat idea to have an NPC that follows you and attacks hostile NPCs. Most of the changes to add this behavior would be in the AI.js script. We will experiment with this for the version after the upcoming update when we have some more time.

    First of all, setting the shoot range to 0 is a good way to make the NPC follow the player. The reason the NPC follows the player using this method is that the Target var of their AI.js component is set in the Start() function of that script like this:

    Code (csharp):
    1.         if(target == null  GameObject.FindWithTag("Player")){
    2.             target = GameObject.FindWithTag("Player").transform;
    3.         }
    To add the behavior like you mentioned, you would have to find a way to dynamically change the NPC's target var when the game is running. One way to do this would be to call Physics.OverlapSphere to get an array of nearby colliders and check their gameObject tags or layers for the ones used by the player and NPC objects. You'd want to call the Physics.OverlapSphere only at a set interval, like maybe every 1-2 seconds for efficiency (a longer interval than the FixedTimestep).

    You could then iterate through the array returned by Physics.OverlapSphere and prioritize targets for the NPC. If the physics sphere doesn't find any enemy NPCs, then their Target could be set to the player object and their attack range set to 0. If the physics sphere does detect hostile NPCs within its radius, the friendly NPC's Target var could be set to the hostile NPC's transform and their Shoot Range could be set to a larger value so they will attack the other NPC. There might be better ways to do this, but this was the first method that came to mind. Hope this info can at least get you started.
     
  46. inglipX

    inglipX

    Joined:
    Aug 9, 2012
    Posts:
    30
    THANK YOU! I can now go around corners ! One more thing though: How can i keep my player fixed horizontally when moving on the ledge? I mainly move left to right on ledges and the player becomes offset sometimes and falls suddenly.
     
  47. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    Thanks a lot for your information! I'll try to create it by myself, it's good that the AI scripts are wrote in .js code, I'm better with JavaScript. :)
    And, I'll be glad if it will be available in the update after this one (if I don't make it till then).
     
  48. xadhoom

    xadhoom

    Joined:
    Sep 2, 2010
    Posts:
    91
    Hi,

    I have a quick question which couldn´t be answered with the demo:

    Does the rigidbody controller allow pushing other players aside (e.g. in a narrow corridor)?

    Thanks,
    xad
     
  49. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Great! For the issue with the player falling from the ledge when moving horizontally, this is probably due to the horizontal/strafe climbing direction begin aligned with the angle of the camera. So if the player is strafing sideways while climbing and they are looking away from the wall, their horizontal velocity will be in the direction perpendicular to the forward direction of the camera, which may lead them away from the climbing surface and off the climbing trigger. A simple work-around for this is to make the climbing triggers stick out further from the climbing surface to give the player more room to strafe horizontally and so they can see when they are climbing too far from the ledge.

    The strafing-off-the ledge behavior is the intended current default of the prefab because it can allow the player to exit a ladder or surface to reach a ledge midway up a shaft, for example. But for a game where there is a lot of horizontal climbing, we understand this is probably not the ideal solution, and we plan on providing more options for climbing in a future update. Thanks for your patience, inglipX.


    Sure Dari, you can ask any questions about doing so in the meantime. Just might need to add a new function or two.


    Hi xadhoom, the demo shows how the rigidbody controller can push rigidbodies and direct its mass onto levers and such, but as for pushing other players or NPCs, it would be easiest if they also had rigidbody components so Unity's physics system could handle their interactions. For the player to be able to push other players, from my understanding, their rigidbody will need a larger mass and/or force than the player to be pushed. You might have noticed that the NPCs in the demo can't be pushed (unless they are ragdolls) since they use character controllers, which don't automatically interact with physics objects without extra coding. Hope that answers your question.
     
  50. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    Just one suggestion, it could be added in version after this one, would be cool, just saying. While crouched distance of the Robots attacking is decreased for x amount of percent/distance in numbers so it looks like you are sneaking, or maybe new thing when press some button, sneaking mode is activated, footsteps sound is decreased like Robot can't hear you, also decrease distance of attacking, and leave crouch system as it is. It's your choice, no need to. :)
     
unityunity