Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Realistic FPS Prefab [RELEASED]

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

  1. KingofMk98

    KingofMk98

    Joined:
    Oct 10, 2013
    Posts:
    63
    Wow! Thank you very much MaartenUT. You've been very helpful!
     
  2. BuildABurgerBurg

    BuildABurgerBurg

    Joined:
    Nov 5, 2012
    Posts:
    566
    Thanks Azuline Studios, I should have remembered the whole Unity 3.5 compatibility reason.

    Thanks for taking your time to explain.
     
  3. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    We are currently using this package....our disadvantages:

    1 - Code is all in C..... there should be a JS version of this package
    2 - High frames like 200 FPS makes the character bob alot.
    3 - No projectile weapons...
    4 - No tag based decal system... we have done this by ourselves.
    5 - No procedural footstep manager... same sound for ground and metal.... fixed this by ourselves.

    The only think that makes us to use this package is the Quality.
     
  4. Deleted User

    Deleted User

    Guest

    Hi KingofMk98, the health and ammo text is rendered on screen using GUIText objects which are referenced by the healthGuiObj var of FPSPlayer.cs and the ammoGuiObj var of PlayerWeapons.cs. These fields are hidden in the inspector by default, but you can comment out the [HideInInspector] lines above the variable declarations to see them in the editor. By default, these references are set to the AmmoText and HealthText objects located in the Assets\!Realistic FPS Prefab Files\!Objects\HUD folder, which use GUIText components and the HealthText.cs and AmmoText.cs scripts to render the text on screen. You can either customize these objects (use a different font, for example) or create another method to display this information to the player, like using a GUITexture to make a health bar. Please let us know if you would like to know more about this.

    It looks like MaartenUT, helped you with your second question. Great job! :)


    No problem MoHoe! The first stage of implementing a thirdperson mode will just be to get the basic framework in place in a way that is as modular/independent of the other scripts as possible. After that, we would like to offer an alternate script or option for using Mecanim as well.


    Hi Shkarface Noori, thanks for your feedback.

    1. We've chosen to use C# for it's speed and consistency of code. Both of these points are largely achieved by the explicit casting required by C#. Though we will look into making javascript versions of our scripts at a later date.
    2. Are you using the most recent version of the asset, 1.17? I just tested this on a windows stand alone build and at framerates varying from 100 to 400 the bobbing speeds were consistent. We did a lot of testing to make sure the animations, bobbing cycles, and other elements were framerate independent. May I ask what platform you building for and noticing this?
    3.Thanks for the suggestion. We've been gradually adding various weapons and a future update will likely include one that introduces moving projectiles in addition to the raycast weapons.
    4. The bullet marks used in the asset are similar to decals, but aren't true decals which wrap around surface geometry. Good to hear you've implemented your own system, this package also seems like a good start. The bullet marks in the most recent version of our asset do use tag-based detection of surface type, if that's what you were asking.
    5. This issue might indicate you are using an outdated version of the Realistic FPS Prefab, as there is support for individual footstep and landing sounds per surface in version 1.17. If you'd like help customizing or setting up this feature, please let us know.

    We really appreciate you sharing your experience with us as it helps us improve the asset.
     
  5. KingofMk98

    KingofMk98

    Joined:
    Oct 10, 2013
    Posts:
    63
    Okay i have another question. How would i go about making a grenade launcher in game. i have the models but i need it to actually shoot grenades instead of bullets. Thanks!
     
  6. MaartenUT

    MaartenUT

    Joined:
    Aug 21, 2013
    Posts:
    18
    Well I can't give any code at this time, but you can initiate a gameobject (the grenade model), add some velocity and force and use the shockwave script from the mine in the demo scene when the grenade model collides (OnCollide void/function).
     
  7. Deleted User

    Deleted User

    Guest

    Hi KingofMk98, MaartenUT has the right idea about instantiating a grenade object that has a rigidbody collider and a script that uses the existing explosion effects and code. I apologize that we don’t have a tutorial or example at the moment on how to do this, but grenades are one of the first features we’ll be working on for the next update. If you can wait until then, we can send you a specific code example. Thanks for your patience.


    The next version is just going through some final checks, then once we’ve updated the documentation, it will be submitted for review to the Asset Store in the next week or so. Here is a preview dev build of the next version. Most of the changes are technical, behind-the-scenes in nature, but you might notice apple and canteen items scattered throughout the map, better weapon movement, and NPC ragdolls that react more realistically to weapon fire. Hope you like it.
     
  8. TheNorthridge

    TheNorthridge

    Joined:
    Jan 4, 2012
    Posts:
    193
    Love the Dev Build, Cant wait to get my hands on it :)

    One question though, is the hunger and thirst systems completely optional? Can they be turned off?
     
  9. unicat

    unicat

    Joined:
    Apr 8, 2012
    Posts:
    425
    Hi, having a Problem here. If i include the FPS Player in my Scene i only can see the Terrain and the decals on the buildings. The buildings are there because i have collision, but they are not visible. This Scene worked fine with ufps. What should i try? Thank you.
     
  10. MaartenUT

    MaartenUT

    Joined:
    Aug 21, 2013
    Posts:
    18
    Is it possible that you have disabled the mesh renderers? Or do you have some sort of script on it that disable it?
     
  11. unicat

    unicat

    Joined:
    Apr 8, 2012
    Posts:
    425
    Mesh renderers are fine, as i said the same Scene works perfect in UFPS. Ah and the trees are visible too :)
     
  12. MaartenUT

    MaartenUT

    Joined:
    Aug 21, 2013
    Posts:
    18
    Do the models only fail to show in-game? Maybe you've tweaked the camera's clear flags to not show the models, try changing the layer of the models :)
     
  13. unicat

    unicat

    Joined:
    Apr 8, 2012
    Posts:
    425
    Camera clear flag is "skybox". Layer of the models is world collision as in the manual. I will try some others, thank you.
     
  14. KingofMk98

    KingofMk98

    Joined:
    Oct 10, 2013
    Posts:
    63
    Can not wait for the new update!
     
  15. Deleted User

    Deleted User

    Guest

    Glad you like the Dev Build, TheNorthridge! The hunger and thirst systems can be toggled on and off by checking the Use Player Thirst or Use Player Hunger boxes of the FPSPlayer.cs component. These options activate/deactivate the pickup items, hunger and thirst timers, and GUI elements for displaying the player’s hunger and thirst attributes. There is also a check box for the health regeneration option too.


    Sorry to hear you’ve encountered an issue displaying your building meshes, unicat. The fact that you mention you’ve set the building objects to layer 10, the world collision layer, and that you can see bullet marks appear on the buildings, indicates that the building colliders are present in the scene and the physics system is interacting with them. It’s strange that you can’t see the building models though, since our scripts shouldn’t be affecting mesh renderer visibility. Are there any errors displayed in the console window? Also, if you create a new scene in the same project and place the buildings, but don’t place the Realistic FPS Prefab or any other objects like landmines, are the buildings still invisible when you run the scene? You might want to check the culling mask of the main camera object to make sure the world collision layer is checked as well. Thanks for your patience.


    The update is almost ready, KingofMk98. A lot of details have been addressed/added that improve the workings and gameplay in the new version :)
     
  16. TheNorthridge

    TheNorthridge

    Joined:
    Jan 4, 2012
    Posts:
    193
  17. KingofMk98

    KingofMk98

    Joined:
    Oct 10, 2013
    Posts:
    63
    Sorry for all the questions but i need some more help. How do i add in my own enemies?
     
  18. MaartenUT

    MaartenUT

    Joined:
    Aug 21, 2013
    Posts:
    18
    A simple way would be to place your character, make sure it has animations named "Take 001" (Not sure if that one is needed), "idle", "run", "shoot" and "walk" and copy the scripts from RobotNPC to your mesh. Be sure to edit the scripts to your liking though.
    That should do the trick, if it doesn't you can always ask more :)
     
  19. KingofMk98

    KingofMk98

    Joined:
    Oct 10, 2013
    Posts:
    63
    it has all the animations and he works but none of the animations play.
     
  20. Deleted User

    Deleted User

    Guest

    Wow, that’s awesome TheNorthridge! Really incredible to see the dialogue system in the demo scene. We’ll add some friendly AI soon that should make conversations with NPCs even better. This is really great. Please keep us updated if you guys are planning to do more with this :)


    Hi KingofMk98, MaartenUT has the right idea. Here is the section from the documentation that covers how to duplicate existing NPCs and replace their character models:

    The first step to adding a new NPC is dragging an existing NPC object from the project library from either Assets\!Realistic FPS Prefab Files\~Demo Scene Assets\~ZombieNPC\Objects for the zombie NPC or from Assets\!Realistic FPS Prefab Files\~Demo Scene Assets\~AlienNPC\!Objects for the robot NPC. Then you can click on the RobotNPC or ZombieNPC object in the hierarchy view and select Break Prefab Instance from the GameObject menu so the original won’t accidentally be overwritten.

    Then you can expand the hierarchy of the duplicated NPC in the Hierarchy window and delete all of its child mesh rendering objects. After you’ve done this, you can locate the new NPC character mesh in the project library, and drag it over the duplicated root NPC object. The animation component of the duplicated NPC object can also be deactivated by checking the box in the upper left of its component window.

    Now we want the AI.js component of the root/parent NPC object to use the animations of the child character mesh you just added to this object. To do this, expand the root NPC object’s hierarchy and drag the child mesh object over the Object With Anims field of the AI.js component. Now, looking in the 3d scene view, make sure that the new NPC character mesh is the right height and fits roughly inside the bounds of the character controller capsule of the root NPC object. If the NPC mesh is too small, you can try increasing its Scale Factor in its Animation Import Settings. You’ll also want to make sure that the imported character mesh has these animations defined in the Animations section of the mesh’s Animation Import Settings: shoot, idle, walk, run (case sensitive). When you test the scene, your new NPC should animate correctly and chase after the player.

    By following these steps, you should be able to create a new NPC prefab object that uses a custom character model. You’ll want to make sure that if the character mesh you want to use imports with an Animation Component attached to its root object, that you disable the Animation Component on the parent NPC object (the one with the AI scripts attached) and then drag your childed character model object over the Object With Anims field of the AI.js component. This is done so the scripts have access to the model’s animations. If you still have any questions about this, please let us know.
     
  21. MaartenUT

    MaartenUT

    Joined:
    Aug 21, 2013
    Posts:
    18
    Hi there Azuline Studios :) I'm really sorry if this is rude in any way, but do you have an ETA for the multiplayer system?

    EDIT: Nevermind, I think I've got something that'll work ;)
     
    Last edited: Oct 20, 2013
  22. KingofMk98

    KingofMk98

    Joined:
    Oct 10, 2013
    Posts:
    63
    Thanks MaartenUT and Azuline Studios for all the help!
     
  23. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    thank you..... I'm using version 1.16!!!!!!!! for some reason we cant reach the Unity Asset Store for the moment, and I'm using Windows 7 Ultimate and same as target build.... and i'm so happy about version 1.18... and the system that i created for Footstep supports both terrain and tag based surfaces ... and you can use textures to check the surface of terrain.. and Randomly chooses from 32 differ audio clips for each footstep surface..... if you wanna try it just let me know. thank you again for the quality.
     
  24. MaartenUT

    MaartenUT

    Joined:
    Aug 21, 2013
    Posts:
    18
    Hi again, I wonder, can I use the weapons included in this asset for commercial use? Not that I'm going to sell the weapons, but I'd like to use just one weapon in it for a kit I'm making (I won't use code out of this asset though ;))
     
  25. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    Hello! :)

    Just one simple question for you, how can I change the Radius of Capsule Collider attached to the FPS Player, because when I change it and run the game, it sets the Radius to 0.5 (default one), and for example I'd like it to be 3. Thanks in advance! Saw the hunger and thirst system too, seems great, also found a little bug: ^^

    Example: if you are holding AK-47 and then you drag some rigidbody item, and then while dragging something, press 'G' to drop the weapon, you will still have the AK in your inventory, and when you pick up the AK that you dropped, it won't add its ammo which is good.
    Just to let you know, excellent asset by the way, very very good, thanks for making it. :)
     
    Last edited: Oct 22, 2013
  26. Deleted User

    Deleted User

    Guest

    No problem KingofMk98, hope the character animations are working for you now.


    The upcoming version has a lot of improvements, especially if you are using version 1.16, Shkarface Noori. Nice job on the footstep system too. We’ll be looking into updating our surface detection method to detect which terrain texture the player is on in addition to the existing tag-based method. Glad you are enjoying the asset!


    If you’ve purchased the main asset, you're allowed to use the included assets however you’d like, MaartenUT. The only exception is if you are considering using assets from our package in one you plan to distribute on the Asset Store. In this case, we ask that you contact us first, as you have, for permission. I’ll send you a PM with the details about the weapon models, thanks.


    Hi Dari, we're glad you're enjoying the asset! The radius of the capsule collider is set by FPSRigidBodyWalker.cs so the playerHeightMod var will scale up the radius of the player capsule proportionately to the height addition amount. You can comment out the code that does this around line 192:

    Code (csharp):
    1. //capsule.radius = 0.5f;
    and line 196:

    Code (csharp):
    1. //capsule.radius = capsule.height * 0.25f;
    Though this will break the crouching feature and possibly some other things. It can be fixed, but we’d have to look into this some more to have the capsule radius not affect raycast heights and other checks. If you want to proportionately increase the height of the player, the best way to do this would be to increase the value of the Player Height Mod amount of the FPS Rigid Body Walker component in the inspector.

    Thank you for pointing out the weapon grab/drop bug! It will be addressed in the upcoming update, but you can fix it now if you want by adding this code around line 98 of PlayerWeapons.cs:

    Code (csharp):
    1.  !FPSWalkerComponent.holdingObject
    so the whole condition check looks like this:

    Code (csharp):
    1.         if(Time.timeSinceLevelLoad > 2.0f//don't allow weapon switching when level is still loading/fading out
    2.          !(!FPSWalkerComponent.grounded  FPSWalkerComponent.sprintActive)//don't allow switching if player is sprinting and airborn
    3.          !switching//only allow one weapon switch at once
    4.          !weaponOrder[currentWeapon].GetComponent<WeaponBehavior>().shooting//don't switch weapons if shooting
    5.          !FPSWalkerComponent.holdingObject//don't allow switching if player is holding an object
    6.          !sprintSwitching){//don't allow weapon switching while sprint anim is active/transitioning
    Hope that helps and thanks again for bringing this to our attention.
     
  27. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    Thanks!!! :)
    Also, am I able to change aiming texture? Because when I try to change it in the inspector it won't work, even if I put boolean Crosshair Enabled = false it won't remove it. Sorry, missed that in the other post, so I had to do the new one! Thanks!
     
  28. Deleted User

    Deleted User

    Guest

    You should be able to change the aiming crosshair texture as you described, Dari. When we added the showAimingCrosshair var to WeaponBehavior.cs to allow certain weapons like sniper rifles to not use an aiming crosshair, the Crosshair Enabled and Aiming Reticle vars of FPSPlayer.cs were broken, it seems. In the next version they will be fixed, although we made it so the pickup/hand reticle will still show even if Crosshair Enabled is false because we feel it’s important for the player to know when they can interact with objects. The pickup/hand reticle can be hidden though, by selecting None for the Pickup Reticle texture. Thanks again for letting us know about any bugs you experience, we really appreciate it.
     
  29. TheAMes

    TheAMes

    Joined:
    Jun 17, 2013
    Posts:
    23
    My gun smoke that comes out when you shoot doesnt appear like it does in your web demo. its more solid and less like smoke? All i done was dropped the fps controller in to my scene which just has a terrain and skybox?
     
  30. TheAMes

    TheAMes

    Joined:
    Jun 17, 2013
    Posts:
    23
    Actually my smoke appears fine but im getting an extra "thing" appearing which looks like a 2d representation of the material that appears, rises then dissapears? sorry hard to explain!
     
  31. TheAMes

    TheAMes

    Joined:
    Jun 17, 2013
    Posts:
    23
    Last edited: Oct 24, 2013
  32. Deleted User

    Deleted User

    Guest

    Hi TheAMes, the smoke texture is a known issue that will be fixed in the upcoming version. If you want, you can download this .psd file and place it in the Assets\!Realistic FPS Prefab Files\Textures folder, overwriting the existing smoke.psd file. Hope that helps.
     
  33. TheAMes

    TheAMes

    Joined:
    Jun 17, 2013
    Posts:
    23
    That works much better thanks
     
  34. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    same problem here
     
  35. Ignoble Arts

    Ignoble Arts

    Joined:
    Feb 9, 2013
    Posts:
    34
    Hi there,
    I have a few questions regarding this system. Recently I had a chat to one of your customers about possibly using the code for a project demonstration. He outlined the strengths and its looks impressive and perfect for the simple little idea we had.
    However, there's a few things we would like to know before we buy it:
    1) How would i apply Deferred rendering to the weapon camera as i gather this is currently hard or impossible to do?
    2) How could we remove the "black underlay" which provides the shadow effect to GUI text as it was pointed out that he had not found an easy way to do so yet?
    Thanks
     
  36. Deleted User

    Deleted User

    Guest

    Hi Ignoble Arts, thank you. I just did a quick test and there doesn’t seem to be any problems running a scene with deferred or forward lighting. Do you want to have shadows from scene objects casted onto the hands and weapon models? This would require the weapon camera component to be deactivated and setting the main camera’s culling mask to include layer 8, the gun layer, and layer 14, the GUI layer. The weapon model positions would also need to be brought toward the camera a bit, but they should be able to cast and receive shadows in the scene. Using light probes with the weapon camera is also an option. Is that what you were asking?

    To disable the black underlay/shadow on the health GUIText, you can select the GUIText object in the project library located in: Assets\!Realistic FPS Prefab Files\!Objects\HUD. Then you can expand the main GUIText rendering object (HealthText) and deactivate/uncheck the GUIText and HealthText components of the child object (HealthText2), which should hide the shadows under the health GUI text on screen. Please let us know if you have any other questions.


    Also, here is a final list of the changes in version 1.18. This update has been submitted to the Asset Store and is going through the review process. It should be available for download soon.
     
  37. Ignoble Arts

    Ignoble Arts

    Joined:
    Feb 9, 2013
    Posts:
    34

    Thanks a lot. The owner of the kit that was reviewed was a little clueless on these points. We'll get this in our shopping cart ASAP.
    Thanks again.
     
  38. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    Hello Azuline!

    I have one suggestion and also one question, thanks for your activity on forums too.

    Suggestion: peek option, if you know what I mean, peeking with "q" and "e" buttons, I think you know because I remember someone asked you about that already in past. Also, I did some script, but it won't work, please give me suggestions or answers.

    By ProjectOne, first post on first page :D
    Thanks

    Script: (this script is for peeking option, but won't work, also, I've tried it on a default camera and it works, also, when I remove "Camera Kick" script from the "Main Camera" object, it work's... but camera gets totally... ummm... bad, you can't look around, you can try it by the way)

    Code (csharp):
    1. var cam : Transform;
    2. var nextPos = 0.0;
    3. var nextPos2 = -0.2;
    4. var dampVelocity = 0.4;
    5. var dampVelocity2 = 0.4;
    6.  
    7. function Update ()
    8. {
    9.  
    10. var newPos = Mathf.SmoothDamp(cam.transform.localPosition.x, nextPos, dampVelocity, .2);
    11. var newPos2 = Mathf.SmoothDamp(cam.transform.localPosition.y, nextPos2, dampVelocity2, .2);
    12.  
    13. cam.transform.localPosition.x = newPos;
    14. cam.transform.localPosition.y = newPos2;
    15.  
    16.   if(Input.GetKey("e"))
    17.   {
    18.       nextPos = .7;
    19.       nextPos2 = 1.5;
    20. }
    21.         else
    22.         {
    23.                 nextPos = 0;
    24.                 nextPos2 = 1.5;
    25. }
    26.         if(Input.GetKey("q")) {
    27.                 nextPos = -.7;
    28.                 nextPos2 = 1.5;
    29.         }
    30.         else
    31.         {
    32.         if(Input.GetKey("c")) {
    33.                 nextPos = -0;
    34.                 nextPos2 = 0;
    35.                 }
    36.         }
    37. }
    Thanks in advance! If you don't have time for my script, ignore it, it's okay! Thanks again! :D
     
    Last edited: Nov 2, 2013
  39. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    Thanks again for your answers.... two questions:

    1 - How Can I Activate an Image effect when I'm rotation at a specified speed like (if rotationSpeed > 2f) .....how can i do that?
    2 - How can i use an image effect if i'm aiming?? i currently did that but i get a little bug... where sometimes i reload the weapon and quickly aim.... the effect is there but its not yet zoomed until reloading.
     
  40. Deleted User

    Deleted User

    Guest

    Thank you, and please feel free to contact us if you have any more questions about the asset.


    Hi Dari, that script looks good. You should be able to get it to work with the CameraKick.cs script, since that is where the camera position is calculated. You just have to add the leaning amount to the camera position calculation around line 120 like this:

    Code (csharp):
    1. Vector3 tempPosition = tempLerpPos + (playerObjTransform.right * dampOriginX) + (playerObjTransform.right * leanAmt) + new Vector3(0.0f, dampOriginY, 0.0f);
    This is how we will be implementing the leaning feature in the next version. Thanks for your feedback!


    Hi Shkarface Noori, for your first question, if you are using the default weapon swaying method calculated in GunSway.cs, you can access either that script’s “localSide” value or the “side” value of Ironsights.cs. This value increases the faster the player moves the mouse and could be used as a multiplier for a rotation effect like you described. It is a small float value, which ranges from 0 to 1.

    To use an image effect for aiming, you can access the public (but hidden in the inspector) bool value “zoomed” of FPSPlayer.cs. This value is true whenever the player is aiming and false when they are not. As far as actually applying the image effect, you can do something like MaartenDEV described in this post:

    Hope that helps.
     
  41. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    thanks, I'm already using the zoom value, but like i said, if you reload and before the reload is done you press aim, then the FOV of cam changes and zoom = true; , even if the animation is not finished, and when the reload is done, its really aiming.. do you know what i mean?
     
  42. vincentellis

    vincentellis

    Joined:
    Oct 21, 2013
    Posts:
    100
    Any ETA for the next version?
     
  43. Deleted User

    Deleted User

    Guest

    Oh, I see what you mean, Shkarface Noori. The reason the zooming var can be true when reloading is to allow the player to press the aim/zoom button while reloading and having the sights rise as soon as reloading is finished. To prevent the zoomed var from being true while reloading you can go to line 414 of FPSPlayer.cs (the 1.18 version) and add the fourth line to the condition check for zooming:

    Code (csharp):
    1.         //toggle or hold zooming state by determining if zoom button is pressed or held
    2.         if(Input.GetKey (zoom)
    3.          WeaponBehaviorComponent.canZoom
    4.          !IronsightsComponent.reloading//add this line to prevent the zoomed var from being true while reloading
    5.          !FPSWalkerComponent.hideWeapon){  
    That should work. We haven't decided if this change should be permanent or not, since allowing the player to press the zoom button during reload and having the sights rise as soon as they can, is convenient, but it does affect the "zoomed" var's ability to be used for other purposes. Thank you for pointing this out.


    Hi vincentellis, version 1.18 is available for download from the Asset Store now. The version after 1.18 will probably be two months or so away, unless there are any urgent fixes that need to be addressed sooner. The next version will be less technical in nature and focused more on adding some additional gameplay features.

    Also, it's important to note that this tutorial about applying damage to NPCs and the player on our blog is in the process of being updated. In version 1.18, there are no longer any SendMessage calls for ApplyDamage functions. The SendMessage calls for damage have been replaced by direct function calls for clarity.
     
  44. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    Thanks Azuline, but there are some errors :(
    If I put that line on 120, the error is following:

    Assets/!Realistic FPS Prefab Files/Scripts/Camera/CameraKick.cs(120,37): error CS0128: A local variable named `tempPosition' is already defined in this scope


    If I replace it with the current tempPosition Vector3, line 111, it says the following error:

    Assets/!Realistic FPS Prefab Files/Scripts/Camera/CameraKick.cs(111,137): error CS0103: The name `leanAmt'
    does not exist in the current context


    What should I do? :)
     
  45. Deleted User

    Deleted User

    Guest

    Thanks for the info Dari. The line of code I posted earlier was to show where to apply the leaning amount to the camera position. There would still need to be some modification of the script you posted for it to work correctly with CameraKick.cs. For a very basic, non-smoothed leaning ability, you could declare this var at the top of CameraKick.cs:

    Code (csharp):
    1. private float leanAmt = 0.0f;
    And add this code near the top of the LateUpdate loop of CameraKick.cs:

    Code (csharp):
    1.             if(Input.GetKey("e")){
    2.                 leanAmt = 0.5f;    
    3.             }else if(Input.GetKey("q")){
    4.                 leanAmt = -0.5f;
    5.             }else{
    6.                 leanAmt = 0.0f;
    7.             }
    Then change this line of code to have the leanAmt added to the camera position:

    Code (csharp):
    1. Vector3 tempPosition = tempLerpPos + (playerObjTransform.right * dampOriginX) + (playerObjTransform.right * leanAmt) + new Vector3(0.0f, dampOriginY, 0.0f);
    You would probably want to implement the smoothing from your script to the leanAmt var in the above code. I wish I could provide a more complete example, but hopefully this might give you a general idea.
     
  46. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    Thank you Azuline for so fast reply, you're the best :D
    Can't wait for new update, I'll need some of those new features for my game :)

    As you wish... :) I'll try it too by myself, will try something with Time.deltaTime.
    By the way, remember when I was asking about how to change/remove reticles/crosshairs? Didn't worked, if I check Crosshair Enabled = false, nothing happens, or if I change the texture, nothing happens, it's always the same reticle, one you have set, I know I'm asking a lot... I'm sorry about that, thanks A LOT in advance!
     
    Last edited: Nov 5, 2013
  47. shkar-noori

    shkar-noori

    Joined:
    Jun 10, 2013
    Posts:
    833
    How can i do that with version 1.16???? cause I changed a lot of behaviors and GUI and GameManagers on version 1.16 which i cant easily upgrade... i have a full game coming with this package.
     
  48. Mister-D

    Mister-D

    Joined:
    Dec 6, 2011
    Posts:
    1,694
    hi azuline studios
    i have an issue when adding water to my scene, whenever i come close to a water plane my screen freezes
    any ideas?
     
  49. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    Any updates on friendly NPC AI? The next release of the Dialogue System has an improved bridge that makes it easy to view and change hit points, hunger/thirst points, and inventory items during conversations. But working with NPCs (such as temporarily disabling their combat AI during conversations) is still kind of kludgy. Do you have any recommendations on how to hook into NPC behavior? Currently conversations just disable the attack script and set the attack/patrol ranges to 0 in the AI script.
     
  50. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,670
    (Sorry, I'd edit my previous post but the forum is having problems right now.)

    Another question: Is there a kill counter? How can I get notified when the player kills an NPC?