Search Unity

Realistic FPS Prefab [RELEASED]

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

  1. inglipX

    inglipX

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

    How could i implement a health regen system for the player. When the player is not being hit by the enemy (zombie) then his health will regen fully after a few seconds of not being attacked.


    Additionally, is there anyway that i can check that the player has a specific gun in either of his gun (2) slots. For example, after purchasing an AK47, i need a variable to check that we have the AK47 so we can not purchase the AK47 if we have it in either of our weapon slots.

    Thanks
     
    Last edited: Aug 23, 2013
  2. SevenBits

    SevenBits

    Joined:
    Dec 26, 2011
    Posts:
    1,953
    This is a basic programming question, not something that's related to this package. You might want to start a thread on this in scripting.
     
  3. inglipX

    inglipX

    Joined:
    Aug 9, 2012
    Posts:
    30
    I know how to code this if i made the prefab.... the health of the player has to do with this prefab therefore it is related to this prefab
     
  4. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,061
    FPSPlayer.cs has a function: HealPlayer(float healAmt). All you need to do is make your script to call that function and tell it how much to heal using a timer.
     
  5. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Hi Defcon44, you can add another weapon prefab object by selecting an FPS Weapons child object (called "AK47" or "MP5" etc.), right clicking on it and selecting duplicate. This is covered in the video later on in the process. Or do you mean that you don't have an additional weapon model to use for a new weapon while following the tutorial? To do this you can go to the Assets\!Realistic FPS Prefab Files\Models\!Weapons folder outside of Unity and duplicate and rename the weapon model you want to make into a new weapon. I might have misunderstood, but I hope the above info is relevant.


    Thanks chelnok! Right now it looks like we might be releasing a smaller update soon with some minor fixes and a few additions like the option to hide the weapon while swimming and an improved sprinting animation method. After that, we will be focusing on more additional features like player leaning. You can continue to try implementing it yourself if you want and we can give advice. The simplest way to do this would probably be to add a positive or negative amount to the right vector of the camera position. The camera position is calculated in CameraKick.cs and you could add the leaning distance similar to the way that "playerObjTransform.right * dampOriginX" is added to the tempPosition (camera position) vector.

    As for the camera going into walls, you might want to do a raycast in the direction and length of the lean, starting at the camera position, and if the raycast detects an obstacle, either prevent the player from leaning or shorten the leaning distance to the length of the raycast before it hits a collider. We will also be working on this in the future, but if you have any more questions in the meantime, please let us know.


    Hi inglipX, basic health regeneration for a non-segmented health bar system is fairly straightforward so we went ahead and implemented it.

    The first thing you can do is add these variable declarations, starting below the maximumHitPoints var, around line 40 of FPSPlayer.cs:

    Code (csharp):
    1.     //player hit points
    2.     public float hitPoints = 100.0f;
    3.     public float maximumHitPoints = 200.0f;
    4.     public bool regenerateHealth = false;//should the player regenerate their health?
    5.     public float maxRegenHealth = 100.0f;//the maximum amount of hitpoints that should be regenerated
    6.     public float healthRegenDelay = 7.0f;//delay after being damaged that the player should start to regenerate health
    7.     public float healthRegenRate = 25.0f;//rate at which the player should regenerate health
    8.     private float timeLastDamaged = 0.0f;//time that the player was last damaged
    Then at the bottom of the Update() loop you can add these lines:

    Code (csharp):
    1.         //regenerate player health if regenerateHealth var is true
    2.         if(regenerateHealth){
    3.             if(hitPoints < maxRegenHealth  timeLastDamaged + healthRegenDelay < Time.time){
    4.                 HealPlayer(healthRegenRate * Time.deltaTime);    
    5.             }
    6.         }
    And finally you can add a statement to set the timeLastDamaged var around line 570 in the ApplyDamage(damage) function:

    Code (csharp):
    1.         if (hitPoints < 1.0f){//Don't apply damage if player is dead
    2.             return;
    3.         }
    4.        
    5.         timeLastDamaged = Time.time;
    And after checking the "Regenerate Health" box of the FPSPlayer.cs component in the inspector, the player should be regenerating health up to 100 HP if they don't receive damage for 7 seconds. You can also tweak the other variable amounts as needed.

    To check if the player has a specific weapon in their inventory, you can use this function:

    Code (csharp):
    1.     //check if the player has a weapon in their inventory
    2.     private bool CheckWeapon(string weaponName){
    3.         //find the PlayerWeapons script in the FPS Prefab to access weaponOrder array
    4.         PlayerWeapons PlayerWeaponsComponent = Camera.main.transform.GetComponent<CameraKick>().weaponObj.GetComponent<PlayerWeapons>();
    5.         //iterate through the children of the FPS Weapons object (PlayerWeapon's weaponOrder array)
    6.         //and check if player has a certain weapon by gameObject string name like "AK47" or "MP5"
    7.         for (int i = 0; i < PlayerWeaponsComponent.weaponOrder.Length; i++)    {
    8.             if(PlayerWeaponsComponent.weaponOrder[i].name == weaponName  PlayerWeaponsComponent.weaponOrder[i].GetComponent<WeaponBehavior>().haveWeapon){
    9.                 return true;//player has the weapon with the string name "weaponName", return true
    10.             }
    11.         }
    12.         return false;//player does not have the weapon with the string name "weaponName", return false
    13.     }
    Note that if you are using this function inside of PlayerWeapons.cs, you won't need to define/cache the PlayerWeaponsComponent and you can access the variables directly. If you want to call the function and determine if the player has a specific weapon, you can do something like this:

    Code (csharp):
    1.             if(CheckWeapon("AK47")){
    2.                 haveAK47 = true;
    3.             }else{
    4.                 haveAK47 = false;    
    5.             }
    Where "AK47" refers to the name of the child weapon prefab/gameObject located under the FPS Weapons object that you want to check.
     
  6. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,061
    Line 914 of WeaponBehavior.cs uses "SendMessageUpwards" to damage the ray cast hit object. Would there be any problems in other codes if I changed that to "SendMessage"? I ask because I am setting up damage zones on my enemy AI and don't really want it to send the damage message to the head, then to the chest, abdomen, hip and so forth since they will all do damage. I can certainly add a conditional if there is problems that use upward everywhere but my AI, but would rather just change that one line if it won't cause problems with other codes you provided with this asset.

    Thanks!
     
  7. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Hi drewradley, the SendMessageUpwards method is used to allow more compatibility with different types of object setups, but changing that call to SendMessage doesn't cause any problems with any of the default objects in the prefab (NPCs, landmines, explosive and breakable objects) because the scripts with the ApplyDamage(damage) functions are all attached to the same object as the collider that is hit by the WeaponBehavior.cs raycast.

    If you wanted, you could also determine the specific object type that is hit by the WeaponBehavior.cs raycast and call a unique damage function on that object without having to use the SendMessage call in the HitObject(hit, direction) function of WeaponBehavior.cs. Using SendMessageUpwards is an easy, slightly less direct way of achieving the same result. Hope that helps!
     
  8. Defcon44

    Defcon44

    Joined:
    Aug 19, 2013
    Posts:
    400
    Azuline thank you for your time
    Made in what I want to do is add a prefab weapon 3D
    I already have the weapon prefab
    It's just that I do not see how to add the weapon to the object which is well framed in the camera.
     
  9. inglipX

    inglipX

    Joined:
    Aug 9, 2012
    Posts:
    30

    Thank you very much Azuline it all worked great!

    I have another question:

    So i am trying to make a GUI text instance like you did with the health and the ammo, so that it maintains its position no matter the screen size. I have tried duplicated the HealthText prefab and duplicated the script and changed the script to display my own text. Then i instaniate the object but the GUI doesnt show at all.... I dont understand:( please help thanks
     
  10. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,061
    Thanks! I ended up using the raycast to determine what it hit and changed to sendmessage when hitting my damage receiver.
     
  11. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Hi Defcon44, if you already have a 3D Weapon model you want to use as a new weapon, you can start by opening/importing one of the existing .FBX models found in the Assets\!Realistic FPS Prefab Files\Models\!Weapons folder in Maya or 3DS Max and matching up your new weapon model's alignment and scale with the existing weapon model. Then you can export your new model and import it into Unity.

    The weapon mesh objects of the default weapons are stored as children of the weapon objects with names like "AK47" and "MP5" and are referenced in the WeaponBehavior.cs script with the Weapon Mesh var. The animated weapon mesh objects usually have the "_Anim" suffix in their name.

    If your new weapon model is already in a format that Unity recognizes, you can import it directly into Unity, align the model's position and scale (preferably using the Scale Factor attribute of the Mesh's Import Settings), then make it a child object of an existing weapon mesh that you've duplicated, and disable the Mesh Renderer component of the original weapon model to hide it. This will allow your new weapon to inherit the existing animations for the original weapon. You can also fine tune the position of the weapon model so the sights line up using the XPosition and YPosition values of the WeaponBehavior.cs component. Hope that helps.


    Glad to hear that info was useful inglipX! Just to get an idea about how you set up your new GUI text. First of all, did you start by duplicating the HealthText object found in the Assets\!Realistic FPS Prefab Files\!Objects\HUD folder, and then rename it to NewText? Then, did you create new variables for the newGuiObj by duplicating the variable declarations and statements in FPSPlayer.cs for the healthGuiObj (including the healthGuiObjInstance vars and statements) and replace the "healthGuiObj" references in the copied lines with "newGuiObj"? After that, did you drag the NewText object from the project library over the newGuiObj field in the FPSPlayer component? You can comment out the "[HideInInspector]" statement above the newGuiObj declaration if it is hidden from the inspector view. Also, you can duplicate HealthText.cs, rename it to NewText.cs and modify it as needed for your new GUIText.

    These steps should allow you to set up a new GUI Text element. Another thing to note, that the instantiated GUI Text objects need to have world position coordinates of 0,0,0 (the origin) because the GUI Text component references the object's world coordinates as well as the offset values in the HealthText/NewText scripts. If you're still encountering issues getting your own GUI Texts to display, please let us know.


    Nice job drewradley, the damage functions can be modified in any way you want (added arguments, multiple targets, ect.) as long as the HitObject function has a valid reference to call. The default ApplyDamage function will be getting a small update soon as well to pass more information about the damage being applied to the target.
     
  12. TheNorthridge

    TheNorthridge

    Joined:
    Jan 4, 2012
    Posts:
    193
    Hi Azuline, any updates on development on the next version?
     
    Last edited: Aug 27, 2013
  13. Andy Charlie

    Andy Charlie

    Joined:
    May 31, 2013
    Posts:
    31
    Hi, firstly i wanna say that you fps kit is really great, overly functional and still easy to use
    Then i have two questions that i hope you could answer
    1.- is possible to make that enemies may fail some shots?
    and 2 .- (this is more like a idea) is possible that the player has an option to use 2 iron sights?, like the option to use semi or automatic fire, but with the sights, like this:
    $600px-Bf4_m16a4_5.jpg

    Thanks for your time!
     
  14. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Hi TheNorthridge, currently we’re working on some bug fixes and minor, but important additions, which might be released as a small update before work starts on more gameplay features. Here’s what’s been done so far:

    • Removed animation check var in CameraKick.cs to prevent rare occurrences of camera becoming unaligned.
    • Replaced GetCurrentProcess() call for quit button with Application.Quit since it has been fixed.
    • Modified smoke texture so its alpha mask will be properly read in newer versions of Unity.
    • Added a lerp to sprinting animation playback for better transition.
    • Fixed playerHeightMod values between 1.0 and 2.0 not allowing player to move.
    • Deleted the RemovePrefabRoot.cs script because it is not needed.
    • Added option for regenerating health.
    • Backwards sprinting is now prevented.
    • Increased item pickup raycast length slightly to make activating scaled-down weapon pickups easier.
    • Added ApplyDamage function parameters for more realistic NPC ragdoll behavior.
    And the unfinished features:

    • Optimize weapon impact particle effects played on certain objects.
    • Option for hiding weapon while underwater.
    • Make sprinting animations more configurable.

    Thank you Andy Charlie! It should be possible to make enemies fire more inaccurately by adding some random values to the direction of the NPC attack raycast in the NPCAttack script. This is something we can add for the new version as well.

    For your second question, to achieve that effect, you probably would use a depth of field, or radial blur shader. We’ll consider adding an option for it, but AFAIK these effects require Unity pro and we also want the asset to be compatible with the free version of Unity.
     
  15. Dernise

    Dernise

    Joined:
    Jun 6, 2013
    Posts:
    1
    Hello Azuline Studios, i'm interested in buying your prefab but one question remain, is there a character model or it's just the arm and the weapon ? I'm planning to make a multiplayer game, that's why I'm asking. If not, would that be hard to add a real character ? I'm not a designer, I'm a c++ developper that is trying to make a game.
     
  16. Andy Charlie

    Andy Charlie

    Joined:
    May 31, 2013
    Posts:
    31
    Thanks for your reply, i already have found some info for my idea, but now lets wait that new release.
    Greetings.
     
  17. Andy Charlie

    Andy Charlie

    Joined:
    May 31, 2013
    Posts:
    31
    I can answers that question. No, the prefab does not contain the complete body and thats because the player camera of a FPS normaly only contain the weapon and the arms, in some cases the body legs (like in battlefield 3), to add a multiplayer mod what is usually done is to add your complete player model whit animations to the player prefab but using camera layers, so that in this way only you see your weapon whit arms and only the others players can se your body model.
    Sorry about my english.
     
  18. JoeTheHunter11

    JoeTheHunter11

    Joined:
    Sep 2, 2013
    Posts:
    3


    I have an issue, My player does not work if i switch the platform to webplayer or google native client. i get this error "Assets/!Realistic FPS Prefab Files/Scripts/Player/FPSPlayer.cs(268,80): error CS1061: Type `System.Diagnostics.Process' does not contain a definition for `Kill' and no extension method `Kill' of type `System.Diagnostics.Process' could be found (are you missing a using directive or an assembly reference?)
    " Please respond :)

    thanks
     
  19. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Hi guys, Andy Charlie is correct. So far only the player's arms and hands are visible from the first person view. Once we're done finishing up some other features, we plan to add a third person view mode which could be used to show other player characters. If you have any other questions please let us know!


    Hi joechancey11, this error is related to the code that detects if the project is being run in the editor, web player, or stand alone. This was added to prevent a crash while exiting using Application.Quit() in previous versions of Unity 4.x stand alone builds. This issue appears to be resolved in Unity 4.2 so you can safely change this 1.17 code for the quit button in FPSPlayer.cs at line 261:

    Code (csharp):
    1.         //Exit application if escape is pressed
    2.         if (Input.GetKey (exitGame)){
    3.             if(Application.isEditor || Application.isWebPlayer){
    4.                 //Application.Quit();//not used
    5.             }else{
    6.                 //use this quit method because Application.Quit(); can cause crashes on exit in Unity 4
    7.                 //if this issue is resolved in a newer Unity version, use Application.Quit here instead
    8.                 System.Diagnostics.Process.GetCurrentProcess().Kill();
    9.             }
    10.         }
    to this:

    Code (csharp):
    1.         //Exit application if escape is pressed
    2.         if (Input.GetKey (exitGame)){
    3.             Application.Quit();
    4.         }
    That change should prevent the error when building the project with Unity 4.2 and up. This will be fixed in the next update, sorry for the inconvenience.
     
  20. sinkler747

    sinkler747

    Joined:
    Dec 10, 2012
    Posts:
    9
    I have a problem with the fps prefab and navmesh. i am using unity pro. whenever I start the game the navmesh uses the prefab as ground zero. and so the navmesh doesn't cover the terrain and pushes other objects along with it. any solutions?
     
  21. Setmaster

    Setmaster

    Joined:
    Sep 2, 2013
    Posts:
    194
    Can anyone say the main difference between Realistic fps prefab and Ultimate fps? I tested both and they seem to do the exact same things.
     
  22. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Hi sinkler747, just responded to your email. Hope the suggestions might help you find a solution!


    Hi Setmaster, the main difference between the two projects is that The Realistic FPS Prefab uses a rigidbody based character controller which is handled by Unity’s physics system and Ultimate FPS uses a character controller based method. The other main difference is that Ultimate FPS uses procedural/run-time methods to animate the player’s weapon and camera, where the Realistic FPS Prefab uses keyframe animations and sine curves which are tweaked as needed.

    There are also other FPS related projects on the Asset Store like the FPS Player Package/Training Day, FPS Kit, FPS Control, FPS Constructor, FPS Controller, and Mobile Starter Pack that you can look into.

    The Realistic FPS Prefab is simply our approach to making an FPS in Unity and reflects our personal tastes as developers and gamers. My advice would be to try out the demos for each asset to familiarize yourself with its features and nuances, then decide which one best suits your project. You can also choose multiple assets and mix-and-match their elements for your own use. If you have any more questions about the Realistic FPS Prefab, please let us know.
     
  23. yunspace

    yunspace

    Joined:
    Nov 8, 2010
    Posts:
    41
    Hi Azuline, I'm trying to integrate authoritative networking into FPS via uLink. Your rigidbody controller would be quite handy since uLink offers support for rigidbody syncing. I've had a quick play around with Ulimate FPS which is also a great product, but the custom physics configurables and events offered by its CharacterController became too complicated for my purposes. So in terms of personal taste, I would rather rely on out of box Unity physics.

    My biggest question is, would it be easy to replace the "2 arm capsule" player prefab with a full body character model. I'm trying to cater for multi-player and potential third person perspective. I really want to avoid maintaining a hands prefab and a separate character prefab for each player, FPS Kit takes this approach but I find the code quite messy and difficult to customise. Let me know what you think, if multi-player is something you are planning in future release then even better! :D

    Also just curious is your rigidbody controller inspired by the RigidbodyFPSWalker: http://wiki.unity3d.com/index.php?title=RigidbodyFPSWalker?
     
  24. yunspace

    yunspace

    Joined:
    Nov 8, 2010
    Posts:
    41
    Oops, just found the answer to my own question, haha. Will have a tinker with this myself tonight, and looking forward to the TPS view.
     
  25. Mixxit

    Mixxit

    Joined:
    Aug 28, 2013
    Posts:
    27
    Is there multiplayer support planned or is anyone working on a multiplayer extension for this that I can purchase? I already own this pack but am considering buying a different fps asset to save me a lot of time - it's a shame really because I truly love the work you have done on this
     
  26. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Hi guys, about thirdperson and networking, it’s something that is on our list, but there are a few other features that we’d like to add to complete our intended “foundation feature set” before moving forward. Version 1.17 is close to that point. I apologize that there isn’t a working multiplayer mode yet, but we want to take the time to research and implement it in the best way we can with results that live up to our standards. We’re quite happy with everything so far and very appreciative of the encouragement :)

    yunspace, for replacing the 2 armed models of the prefab with a thirdperson model, the base capsule collider/rigidbody character controller (which is inspired by the wiki script, with a lot of additions and improvements) can still be used for movement and collision detection, since it is invisible and works behind-the-scenes. So it’s really only the mesh animation code that needs to be modified, as well as the camera method and a few other details. Hope that answers your questions.
     
  27. Mixxit

    Mixxit

    Joined:
    Aug 28, 2013
    Posts:
    27
    Woohoo it's official! Can you add vehicles on that list? There is no fps pack with vehicles and multiplayer!
     
  28. Mixxit

    Mixxit

    Joined:
    Aug 28, 2013
    Posts:
    27
    I'm having an issue where a player is getting stuck and is unable to move or walk any more. The terrain itself at the spot is pretty flat and i don't see any issue with it. Do you know how i can resolve this?
     
  29. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Hi Mixxit, vehicles are a possibility, but it wouldn’t be for a while yet as we’d like to finalize some other features first. When you mention that the player is getting stuck, have you increased the Player Height Mod value of the FPS Rigid Body Walker component to an amount lower than 2.0 and above 1.0? This can cause a known glitch that will be fixed in the next version. There are instructions in this post on how to correct it.

    You can also try increasing the Slope Limit value of the FPS Rigid Body Walker component. The default is 40, which might be a bit low. If you still are experiencing this, could you please post or PM a screenshot of the terrain that that is causing the issue? Thanks for your patience.
     
  30. Mixxit

    Mixxit

    Joined:
    Aug 28, 2013
    Posts:
    27
    Hi certainly

    This is the slope that is causing the problem:

    $roadstuck.png

    I have not changed any of the settings you mentioned they are all stock values but I will take a look at them
     
    Last edited: Sep 6, 2013
  31. Mixxit

    Mixxit

    Joined:
    Aug 28, 2013
    Posts:
    27
    However since testing, I have found that if i remoev the easyroad3d from the area i will instantly fall a small amount to the terrain and be able to walk again

    $terrainnotstuck.png

    Ideas?
     

    Attached Files:

  32. jeff.fnd

    jeff.fnd

    Joined:
    Jul 31, 2013
    Posts:
    10
    Have you any idea of ​​when the update might go to third person?

    Or give some hint of how we can implement the third person in this project?
     
  33. decerto

    decerto

    Joined:
    Jun 1, 2012
    Posts:
    128
    Just curious, will the price be increased once the multiplayer and third person is in? I don't want to pick this up until those features are in, but don't want to pay extra. Just wondering.

    Thanks,
     
  34. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Hi Mixxit, have you tried setting the easyroad3d object’s layer to 12, the World Collision layer? That might help. I’ve tried to recreate the setup in your screenshots, but haven’t been able to make the player get stuck. We will look into this some more to see if we can make some improvements. Do you know what kind of collider the easyroad3d object uses?


    We’re planning to add a third person mode in the update after the upcoming one, jeff.fnd. I don’t have an exact date yet, as some experimentation and research will be involved, but we will keep you current on our progress.

    As far as implementing third person on your own, if you are familiar with the layout of our scripts and objects, it would be a matter of deactivating certain FPS features and seamlessly switching to third person features in real-time. We are still in the planning phase for this, but to get a very basic (and somewhat buggy) third person mode, you can change this code around line 103 of CameraKick.cs from this:

    Code (csharp):
    1. Vector3 tempPosition = tempLerpPos + (playerObjTransform.right * dampOriginX) + new Vector3(0.0f, dampOriginY, 0.0f);
    To this:

    Code (csharp):
    1. Vector3 tempPosition = tempLerpPos + (playerObjTransform.right * dampOriginX) + new Vector3(0.0f, dampOriginY, 0.0f) + (playerObjTransform.forward * -3.0f);
    And change this code around line 260 of PlayerWeapons.cs from this:

    Code (csharp):
    1.  
    2.         //align weapon parent origin with player camera origin
    3.         Vector3 tempGunPosition = new Vector3(mainCamTransform.position.x, mainCamTransform.position.y,mainCamTransform.position.z);
    4.  
    To this:

    Code (csharp):
    1.         //align weapon parent origin with player camera origin
    2.         Vector3 tempGunPosition = new Vector3(playerObj.transform.position.x, playerObj.transform.position.y + 0.5f, playerObj.transform.position.z);
    These changes will offset the camera to follow the FPS Player object and place the weapon models at the character’s position instead of the camera position. You can also add a mesh filter with a capsule mesh and mesh renderer component to the FPS Player object to see an outline of the player’s collision capsule in the scene.

    This is far from perfect as a few features are dependent on the camera position instead of player position (melee damage, item pickups), but this can all be toggled with a third person bool. Also, a player model animation method will need to be implemented as well. Hope this at least gives you some ideas.


    Hi decerto, there won’t be a price increase for third person mode or any upcoming gameplay related updates. It’s too early to tell if there will be a price increase for vehicles or multiplayer as I don’t know how much time they will involve or how they would be released, but we’re leaning towards not raising the price too much, if at all. If you have any other questions, please let us know.
     
  35. Luca91

    Luca91

    Joined:
    Apr 13, 2013
    Posts:
    75
    Hello dear mates,
    first of all I'd like to thanks Azuline Studios for the awesome product!
    I've noticed that the pathfinding of NPCs is a bit problematic for levels with parts where you can fall down, or if your level have some obstacles, so since yesterday "A* Pathfinding Pro" was on discount, I bought it.. Does anybody managed to integrate A* Pathfinding AI with Realistic FPS Prefab AI ?

    I'll try myself, but if anybody have already done it, please give me some advices so I can save a lot of time and pains :p
     
  36. zackbradley16

    zackbradley16

    Joined:
    Sep 5, 2013
    Posts:
    1
    Hi,

    Ok I was trying to build and run my project and about half way through it this pops up. Assets/!Realistic FPS Prefab Files/Scripts/AI/AI.js(66,34): BCE0018: The name 'CameraKick' does not denote a valid type ('not found'). Did you mean 'System.Runtime.InteropServices.ComRegisterFunctionAttribute?

    how do i get rid of this error?
     
  37. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Hi Luca91, thank you! Glad you're enjoying the asset. We responded to your email. The AI path finding will be getting an improvement soon, but please let us know if you have any specific questions in the meantime.


    Hi zackbradley16, it sounds like the error you’re describing is due to compiling the AI.js script with #pragma strict or building for a platform that uses strict casting automatically like Android. This causes an error with AI.js because it uses a GetComponent call on the C# script CameraKick.cs. We will be converting all the javascripts in the asset to C# soon, which will prevent this from happening, but in the meantime, you can follow these steps for version 1.17, and the errors should stop:

    First, you can move all the script folders except the one named AI from the Assets\!Realistic FPS Prefab Files\Scripts directory to a new folder called Standard Assets located in Assets\Standard Assets from within the project library window in Unity to maintain component links (not the OS folder explorer). Then you can change line 66 of AI.js from this:

    Code (csharp):
    1. playerObj = Camera.main.transform.GetComponent("CameraKick").playerObj;
    to this:

    Code (csharp):
    1. playerObj = GameObject.Find("!!!FPS Player");
    If you don't want to use GameObject.Find (it won't be used in the updated script), you can uncomment line 66 and the @HideInInspector statement above the playerobj declaration in AI.js and drag the !!!FPS Player object over the exposed playerObj fields of the AI.js components manually.

    Then you can change line 153 of AI.js from this:

    Code (csharp):
    1. var FPSWalker = playerObj.GetComponent("FPSRigidBodyWalker");
    to this:

    Code (csharp):
    1. var FPSWalker : FPSRigidBodyWalker = playerObj.GetComponent("FPSRigidBodyWalker");
    And the project should compile for Android or #pragma strict without errors. There might be a few warnings about shader clip instructions and implicit casting of an AutoWaypoint var, but they don't seem to cause any problems. We are in the process of improving and converting the AI scripts to C# which should solve these compilation issues for future versions. Hope that helps.
     
    Last edited: Sep 12, 2013
  38. Luca91

    Luca91

    Joined:
    Apr 13, 2013
    Posts:
    75
    I saw the email, thank you :) I'd like to inform that today I've got some nice results: I've rewritten the AI and I've integrated the pathfinder :) Face 2 face attacks works perfectly and my enemies can now avoid obstacles!
    Tomorrow I'll work on ranged attacks AI.. I hope to get nice results here too..
     
  39. wisien92

    wisien92

    Joined:
    Nov 16, 2012
    Posts:
    56
    I have problem ... when i play in Unity my level i can pick and throw objects but once its built i cannot do that ... dunno why

    few warnings

    Code (csharp):
    1. Assets/Standard Assets/Scripts/General Scripts/ActivateTrigger.cs(43,58): warning CS0618: `UnityEngine.GameObject.active' is obsolete: `GameObject.active is obsolete. Use GameObject.SetActive(), GameObject.activeSelf or GameObject.activeInHierarchy.'
    2.  
    3. Assets/Standard Assets/Scripts/General Scripts/ActivateTrigger.cs(53,58): warning CS0618: `UnityEngine.GameObject.active' is obsolete: `GameObject.active is obsolete. Use GameObject.SetActive(), GameObject.activeSelf or GameObject.activeInHierarchy.'
    4.  
    5. Assets/Standard Assets/Scripts/Utility Scripts/MeshCombineUtility.cs(27,74): warning CS0618: `UnityEngine.Mesh.GetTriangleStrip(int)' is obsolete: `Use GetTriangles instead. Internally this function converts a list of triangles to a strip, so it might be slow, it might be a mess.'
    6.  
    7. Assets/Standard Assets/Scripts/Utility Scripts/MeshCombineUtility.cs(130,73): warning CS0618: `UnityEngine.Mesh.GetTriangleStrip(int)' is obsolete: `Use GetTriangles instead. Internally this function converts a list of triangles to a strip, so it might be slow, it might be a mess.'
    8.  
    9. Assets/Standard Assets/Scripts/General Scripts/ActivateTrigger.cs(43,58): warning CS0618: `UnityEngine.GameObject.active' is obsolete: `GameObject.active is obsolete. Use GameObject.SetActive(), GameObject.activeSelf or GameObject.activeInHierarchy.'
    10.  
    11.  
    12. Assets/Standard Assets/Scripts/General Scripts/ActivateTrigger.cs(53,58): warning CS0618: `UnityEngine.GameObject.active' is obsolete: `GameObject.active is obsolete. Use GameObject.SetActive(), GameObject.activeSelf or GameObject.activeInHierarchy.'
     
    Last edited: Sep 14, 2013
  40. Dari

    Dari

    Joined:
    Mar 25, 2013
    Posts:
    130
    Moving mouse to x0 and y0 position when game is paused. What's the code for that, I'd like to see it :D
    I searched some stuff on internet and it says that you need to have some other program to make it, is that true? o_O
     
  41. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    That’s great news Luca91! The FPS features of the asset have been designed to be self-contained, with the included AI as a separate element. So any AI system should be compatible with the player prefab scripts by using the ApplyDamage() function to send damage amounts the NPCs and player. Keep up the great work :)


    Hi wisien92, the warnings you listed appear to be related to using Standard Asset scripts from a previous version of Unity with a newer version. Unity 4.0 changed the way that game objects are activated and deactivated. So one thing you can try is to move the Assets/Standard Assets folder outside of your project so they won’t be read by Unity, and then try compiling or running the scene again. If you moved all our scripts to the Standard Assets folder for compatibility with strict build settings (android or #pragma strict), you can leave them there, but move the other standard asset scripts.

    Another thing to do might be to create a new, blank project without any packages imported, and just import the Realistic FPS Prefab. If that doesn’t solve the object dragging issue, please let us know.


    Hi Dari, the Input.MousePosition is read only so to modify the cursor position, you would probably need to hide the OS mouse cursor, create you own mouse cursor to display on the screen using a GUITexture or similar method, and then calculate your new mouse cursor position relative to the Input.MousePosition, which would allow the cursor to be initialized at different screen coordinates as needed.

    Here is a brief post about the mouse position question, and another post where there is discussion about how to calculate a position relative to the input.MousePosition. The GUI tools in the new version of Unity or a GUI plugin might also help with this. I wish I had a specific example on how to do this, but we’re very busy at the moment working on the next update. Hopefully the links I posted might give you some ideas.
     
  42. chelnok

    chelnok

    Joined:
    Jul 2, 2012
    Posts:
    673
    I tried to check from earlier post, but couldnt see ..sorry if this already asked / answered.

    Any plans about focusing either unityscript or csharp? I really hope you drop the unityscript and convert all scripts to c#. Its not a big thing, but for example when making my own addones to scripts ..and for example when i need to use unityscript - c# communication i have to put my scripts to Standard Assets folder. Not a biggy, but i prefer keep scripts in order if possible :)
     
  43. wisien92

    wisien92

    Joined:
    Nov 16, 2012
    Posts:
    56
    Creating new project did the job :)

    Thanks for help
     
  44. Andy Charlie

    Andy Charlie

    Joined:
    May 31, 2013
    Posts:
    31
    Hello, i have a little question, how to add healt to an object? i add the CharacterDamage script to a object with a capsule collider and also with the die sound and dead replacemente, but when i shot him nothing happens. Please help
     
  45. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Hi chelnok, the AI scripts are the only ones in unity/javascript at the moment, but we’ll be converting them to C# soon. This will be done for the reasons you mentioned and to allow the scripts to communicate more easily. Thanks for your feedback.


    Good to hear wisien92. Sometimes if there are errors in separate scripts they can interfere with others too. Especially if the errors are null refs, we’ve noticed.


    Hi Andy Charlie, you might want to have a look at this post on our blog that discusses how to damage the player and NPCs. First of all, the object you're shooting should be on a layer that is used by the weapon raycast (the NPC layer is layer 13 by default). The layers included in the Bullet Mask var of the WeaponBehavior.cs script will be checked for impacts by weapons. You can also use the BreakableObject.cs script if you are trying to create a destructible scene prop, though the object will need a mesh particle emitter component as well. Hope that helps.
     
  46. raymondle

    raymondle

    Joined:
    Sep 14, 2013
    Posts:
    2
    Hi Azuline. I try to fix error by your step by step at here

    But it have error here

    P/s : Have a error when i switch Build Setting from Windows x86 to Windows Store XAML(or D3D) C#
     
    Last edited: Sep 17, 2013
  47. Azuline-Studios

    Azuline-Studios

    Joined:
    Apr 5, 2013
    Posts:
    203
    Hi raymondle, this error occurs when the javascript AI.js uses GetComponent calls to access C# scripts when using strict build settings. Line 156 of Ai.js should be changed from this:

    Code (csharp):
    1. var FPSWalker = playerObj.GetComponent("FPSRigidBodyWalker");
    to this:

    Code (csharp):
    1. var FPSWalker : FPSRigidBodyWalker = playerObj.GetComponent("FPSRigidBodyWalker");
    Then, all FPS script folders except the one named AI from the Assets\!Realistic FPS Prefab Files\Scripts directory should be moved to a new folder called Standard Assets located in Assets\Standard Assets from within the project library window in Unity. This is the last step to make Unity compile the C# scripts first so the javascripts will be able to access them. The compiling issue will be resolved when the AI scripts are converted to C#. The steps we posted are a temporary workaround that allowed us to compile for Android and #pragma strict. If you still encounter the error when building for the Windows Store platform, we apologize, as this will be fixed this soon. Thanks for your patience.
     
  48. Andy Charlie

    Andy Charlie

    Joined:
    May 31, 2013
    Posts:
    31
    Hello, i have a problem with the regenerate health implement, in the second step when i try to add the code lines this happens:

    $Sin título.png

    what did i do wrong?
    thanks for your time
     
  49. MoHoe

    MoHoe

    Joined:
    Nov 5, 2012
    Posts:
    566
    Andy Charlie I suggest you go to this link and watch the video, you will find the answer there.

    here's the link

    You will have to learn the basics before customizing asset code. I don't speak on behalf of realistic FPS prefabs. Just my opinion and probably many others.
     
  50. Andy Charlie

    Andy Charlie

    Joined:
    May 31, 2013
    Posts:
    31
    Wow, this is amazing, the video doesn't have exactly the answer, but after seeing and thinking about what the video said i try again to edit the code and it was fine in the first try.

    thank you very much for your answer