Search Unity

Realistic FPS Prefab [RELEASED]

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

  1. AdriaFace

    AdriaFace

    Joined:
    Jul 28, 2013
    Posts:
    9
    Azuline how do i do to change the Health Starting Value?

    Thanks so much!:D
     
  2. Deleted User

    Deleted User

    Guest

    Andy Charlie, so did you figure out the issue? From the screenshot, it looks like you pasted the code outside of the Update loop brackets/braces. Sorry if that was unclear when the instructions said to paste the code at the bottom of the Update loop. Should probably have clarified that the code needed to stay inside the Update loop brackets too.

    MoHoe, thanks for helping out. Awesome link you posted as well!


    Hi AdriaFace, you can change the player’s starting hit point amount by modifying the Hit Points value of the FPSPlayer.cs component attached to the FPS Player object in the inspector window. You can change the hit point limit for the player with the Maximum Hit Points var as well. Hope that helps.
     
  3. Andy Charlie

    Andy Charlie

    Joined:
    May 31, 2013
    Posts:
    31
    yes, solved the problem, and actually just change the code position, thanks for your time
     
  4. inglipX

    inglipX

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

    How did you have the FPS player (the capsule) rotate with the mouselook?
     
  5. Deleted User

    Deleted User

    Guest

    Great! Glad you got it working.


    Hi inglipX, the player capsule’s Euler Angles are set to that of the camera parent object, (which is rotated by the mouselook script) in the FPSRigidBodyWalker.cs script around line 806, before the player movement velocities are calculated. This is done to synchronize the rotations, but it also allows independent rotations of the camera or player capsule in certain situations.
     
  6. OneShotGG

    OneShotGG

    Joined:
    Nov 16, 2012
    Posts:
    225
    So, just to show off how powerful and extendable the Realistic FPS prefab can be, here is the Realistic FPS Prefab Third Person Style.

    Things to note:
    - animation driven by mecanim
    - aiming driven by headlookcontroller
    - over 50 hours of work to convert, tweak and extend the Realistic FPS scripts
    - custom camera with two modes orbit and over the shoulder
    - heavily modified weapon system to work with both our project goals and third person shooting
    - TPSRigidBodyWalker script with two movement types; free run(orbit cam) and Locked Perspective(over the shoulder cam)
    - demo of multiple colliders(triggers) to allow specific damage amounts for specific body parts (ie headshots)
    - wall jumping with a rigidbody

    disclaimer: All animations are place holders (my animator is hard a work getting our animations out).

    [video=youtube_share;6MrLyxmuDdc]http://youtu.be/6MrLyxmuDdc


    I just want to thank Azuline Studios for such an awesome prefab. It has made the development of our game idea so much easier.


    edit. One question Azuline, when the character gets parented to a moving platform the characters scale gets changed. This leads to weird mesh scale issues when the character steps off of the platform. Is there any way to stop this from happening?
     
  7. Deleted User

    Deleted User

    Guest

    Hi oneShotGG, thanks for the kind words, and wow, amazing work! Really nice :D

    To answer your question about object parenting, in the current version of the prefab, there are two main ways we get around the scaling and movement issues involved with parenting objects. The first method is to parent only the player rigidbody to the platform or elevator and have the camera (or TPS player mesh object) keep the world transform as their parent (transform.parent = null). Then you can lerp or damp the rendering object’s position with the rigidbody position. This is how we improved the ejected shell and camera movement code for version 1.17 to be smooth with any fixed timestep or framerate, even though the rigidbody isn’t interpolated. Having rigidbody interpolation turned on and making those rigidbodies children to other objects can cause movement problems at varying framerates.

    The second method compensates for parenting objects to other objects that have been unevenly scaled/skewed in the editor. This can happen when a cube is stretched longways to create a wall and when an object is made a child of the wall object, they inherit the uneven scaling. We got around this for bullet mark objects in the WeaponEffects.cs script around line 255 by creating an empty game object to serve as another layer between the skewed object and the bullet mark, and then calculating the inverse of the skewed object’s scale and applying it to the bullet mark object’s scale. Either solution might work for you, but if you need some more information on this, feel free to let us know on this thread, by PM, or email. Again, great work you guys have done!
     
  8. MaartenDEV

    MaartenDEV

    Joined:
    Sep 26, 2013
    Posts:
    11
    Hey Azuline Studios :) I AM LOVING THIS. I've had it for 2/3 days (I don't remember exactly) and I've added bullet drop with damage and stuff, and for me this is perfect! It's so smoothly made :D + for other users, for a realistic scope effect - you'll need Unity Pro - try using a render texture, and then use it on a plain in the scope :)
    But, one tiny request, a smoother parkour/parcour (sorry, this isn't my native language) would be nice. Don't get me wrong, the script you're using is functional, but it doesn't look that profesional. So, if you could include that in the next update it'd be great, or if you could help me a bit so I can make it myself :)
     
  9. Andy Charlie

    Andy Charlie

    Joined:
    May 31, 2013
    Posts:
    31
    Hello MaartenDEV, you mind sharing with us what do you make to add bullet drop? and i could tell you a idea to make the parkour system more professional, and other idea to make that render texture scope more realistic or natural.
     
  10. snowboardkid

    snowboardkid

    Joined:
    Jun 16, 2013
    Posts:
    17
    What parkour system are you guys talking about?
     
  11. MaartenDEV

    MaartenDEV

    Joined:
    Sep 26, 2013
    Posts:
    11
    You can simply instantiate a bullet prefab, add some velocity and force, and then use a script on the bullet to use CharacterDamage.ApplyDamage on collision :)
    And for the scope, do you guys know where in IronSights.cs I can enable and disable a DepthOfField image effect?
     
  12. MaartenDEV

    MaartenDEV

    Joined:
    Sep 26, 2013
    Posts:
    11
    You can see an example in the ObstacleCourse.unity scene :)
     
  13. Andy Charlie

    Andy Charlie

    Joined:
    May 31, 2013
    Posts:
    31
    Hi, first, from where you from? or what is your language?
     
  14. Venged

    Venged

    Joined:
    Oct 24, 2010
    Posts:
    500
    Is the TPS Prefab included now?

    Thanks
     
  15. Andy Charlie

    Andy Charlie

    Joined:
    May 31, 2013
    Posts:
    31

    Nope
     
  16. MaartenDEV

    MaartenDEV

    Joined:
    Sep 26, 2013
    Posts:
    11
    Dutch, The Netherlands :) And I'm 13 so that might affect my language too.
     
  17. Deleted User

    Deleted User

    Guest

    Good to hear you’re enjoying the asset MaartenDEV! We understand that the current parkour system is rather basic, as it is more of a prototype/proof-of-concept feature, but we plan to expand on it in a future update. The improvements probably won’t be in the next update, as it includes some needed technical fixes and it’s almost ready for release.

    What sort of improvements would you want for the parkour system? We can answer any questions you might have about adding specific improvements. As for our ideas, we were thinking of making it so the player can look freely as they climb across a parallel surface (instead of moving in the look-direction), adding camera and player hand climbing animations, and possibly making the ledge-climbing more constrained so the FPS hands will line up to the ledge they have “locked on” to.

    There’s a lot of features on our list, so we’re trying to order the tasks in a way that is logical and to complete some previously requested FPS-related additions. It might be better to add the parkour system after third person mode is implemented so either the camera can be in full third person mode while climbing, or to allow the player’s body to be seen in FPS mode. Thanks for your patience.


    To add a DOF effect to the Ironsights.cs script, you might want to look below line 330, where most of the zooming related effects, like camera FOV and weapon position changes, are activated when the player zooms. Hope that helps.


    Hi Venged, the video above was from OneShotGG’s own project and shows how the asset can be customized by changing the scripts. Here is a post where we discussed how to make a very simple third person mode. A full third person mode is on the list for a future update. If you have any more questions about this, please let us know.


    The next update is coming along well and should be ready after a bit more testing. Here is a list of the changes for the next version. A lot of them are mostly technical fixes, but we felt it was important to take some time to make these improvements to lay the groundwork for the other planned features:

    • Removed animation check var in CameraKick.cs to prevent rare occurrences of camera being 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 smoothing to sprinting animation playback for better motion transition.
    • Fixed playerHeightMod values between 1.0 and 2.0 not allowing player to move.
    • 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 (the SendMessage calls for ApplyDamage() will be replaced with more direct/efficient ones now that AI scripts have been converted to C#).
    • Optimized shotgun impact particle effects played on NPCs.
    • Improved timing of ejected shell rotation.
    • Added options for hiding weapon when player is underwater or holding an object.
    • Added inaccuracy var to NPCAttack.cs to allow enemies to miss on their attacks.
    • Made automatic weapon's recoil spread recover when the fire button is released instead of waiting for semi auto shot timer.
    • Added optional player hunger and thirst attributes which are reduced by apple and canteen pickups
    • Updated uncrouching obstacle check to prevent player from uncrouching into overhead geometry in some situations.
    • Hard-coded the raycast slope limit angle in FPSRigidBodyWalker.cs to 60 to prevent player from getting stuck in small indents or tight spaces (the capsule check slope limit can still be customized).
    • Scripts now prevent dragging objects while player is zoomed or dead.
    • Added kick back amount variables to WeaponBehavior.cs to allow slight backward motion of weapon during sustained fire.
    • Weapon z position (forward back) for zoomed, unzoomed, and sprinting states are now customizable from the inspector.
    • Added removePrefabRoot bool to WorldRecenter.cs script and deleted RemovePrefabRoot.cs script to allow option for keeping the FPS Main prefab root object or deleting it on scene load to allow the world recenter script to keep the FPS Player object's local and world coordinates synchronized to prevent spatial jitter and allow larger scenes.
    • Converted AI scripts from javascript to C# to allow easier compilation for android and windows projects and better communication between scripts.
     
    Last edited by a moderator: Sep 29, 2013
  18. Litwin

    Litwin

    Joined:
    Aug 15, 2013
    Posts:
    70
    @Azuline Studios
    You want to create new updates?
     
  19. Andy Charlie

    Andy Charlie

    Joined:
    May 31, 2013
    Posts:
    31
    Ok, i just wanna know if we have the same languages so we can
    speak in than one, but im from mexico, to do that DOF effect, like in cryengine 3 i suppose, just add that image effect to the main camera, then make a script that enable the effect when the right mouse button (the aiming button) is pressed, and disable the effect when it is not currently pressed. You can find more information here http://answers.unity3d.com/questions/36182/enabledisable-image-effects-in-code.html
     
  20. MaartenDEV

    MaartenDEV

    Joined:
    Sep 26, 2013
    Posts:
    11
    Yeah I've already made it :D Thanks anyway :)
     
  21. lod3

    lod3

    Joined:
    Mar 21, 2012
    Posts:
    679
    Any chance you would consider selling this modified script? :)
     
  22. MaartenDEV

    MaartenDEV

    Joined:
    Sep 26, 2013
    Posts:
    11
    Can't, I can't resell any part of this pack. I'll just upload some parts in a sec, be patient :)
     
  23. MaartenDEV

    MaartenDEV

    Joined:
    Sep 26, 2013
    Posts:
    11
    Okay here it is,
    Line 36:
    Code (csharp):
    1.     public Camera DOFCam;
    Line 335:
    Code (csharp):
    1. (DOFCam.gameObject.GetComponent("DepthOfFieldScatter")as MonoBehaviour).enabled = true;
    Line 394:
    Code (csharp):
    1. (DOFCam.gameObject.GetComponent("DepthOfFieldScatter")as MonoBehaviour).enabled = false;
    '

    And then just assign the camera with the DOF component to the DOFCam thing :)

    PS: There are probably more efficient ways of doing this, this is just what I could come up with myself ;)
     
    Last edited: Sep 29, 2013
  24. Andy Charlie

    Andy Charlie

    Joined:
    May 31, 2013
    Posts:
    31
    Hey, i know what could be a good or necessary feature for the next update, simple as three modes for player stand, the normal, then crouch and then go prone, like all the fps games.
     
  25. Kazzack

    Kazzack

    Joined:
    Mar 8, 2013
    Posts:
    27
    Hey man, i do love your amazing asset!
    How would you go about using/changing the AI script from the robots from instead of patrolling, and then hunting and killing you. To Following the player / (Carry on normal patrol), but instead of shooting and killing the player, kill (for example) the zombies from your demo scene. Would that be cool or what?

    Would you be ever planning to add this or if not send me in a direction so i could do it manually with your asset?

    Thanks :)

    EDIT... I mean i'm pretty sure half the code is there, but just tweaking the scripts a little might do it? I'm not too sure :)

    I'll give it a little go myself tonight, but i'm not too confident i'll get anywhere ;)
     
    Last edited: Sep 30, 2013
  26. Andy Charlie

    Andy Charlie

    Joined:
    May 31, 2013
    Posts:
    31
    You could change the tag in the enemy AI script, change the "player" tag for the tag of the enemy, in this case the tag of the zombie
     
    Last edited: Oct 1, 2013
  27. Deleted User

    Deleted User

    Guest

    Hi Litwin, yes, the Realistic FPS Prefab will continue to receive updates that include fixes and new features. Your feedback really helps us to improve the asset!


    Hi Andy Charlie, prone stance is on the list and should be implemented soon. Thanks for the suggestion.


    Good to hear you’re enjoying the asset, Kazzack! To add friendly NPCs, the AI scripts will need two target vars, one for the player so NPCs can track and follow them, and another target var for hostile NPCs. Then a new function could be written or an existing one could be modified to use the new target objects.

    You could also try what Andy Charlie said and switch the target assignment from the player object to an enemy NPC, but you would also need to add a check for when the NPC’s target died so they can find a new one, since currently, they only assign the player as their target on scene load and don’t acquire new targets.

    We will be looking into adding friendly NPCs soon as well, hope the wait won't be an inconvenience. Modifying the NPC AI will be a lot more straightforward after the new update too, which includes AI scripts written in C#.
     
  28. MaartenDEV

    MaartenDEV

    Joined:
    Sep 26, 2013
    Posts:
    11
    Hey Azuline Studios, now you´re here, could you recommend a service like photon or something like that for using multiplayer? It should be easy to use, and the server doesn't need to be that fast, as it's for personal use with friends :)
     
  29. Kazzack

    Kazzack

    Joined:
    Mar 8, 2013
    Posts:
    27
    Well i'm not too good at scripting, so unless your willing to pretty much spoon feed me, or a very detailed explanation, i'll guess i'll have to wait for the update and documentation for it ;)
     
  30. Litwin

    Litwin

    Joined:
    Aug 15, 2013
    Posts:
    70
    @Azuline Studios
    I love your project, congrulations!

    - Could improve the system Sniper? Something like BF or leave more real, with the best sights.
    - Improve a Dynamic Crosshair
    - And, have anyone chance for physic to Cars?
     
  31. Khazzack

    Khazzack

    Joined:
    Sep 27, 2013
    Posts:
    29
    Well the sights you can add yourself. Just need to get the models of the sniper with the "best sights" and replace the models he uses.
     
  32. Deleted User

    Deleted User

    Guest

    Hi MaartenDEV, we are looking into the best way to implement multiplayer for the asset, so any recommendations at this point will still need some testing and development. First of all, Photon Networking does seem like a good place to start. You can also experiment with writing your own networking solution, maybe by using this tutorial or this guide from Unity as a starting point. As we continue to release new updates, things should get progressively better as we add features that make set up for a network environment easier. Thanks for your patience.


    Hi Kazzack, I wish I had some step by step instructions for you on how to add friendly NPCs, but we are currently working on making some improvements to the C# AI scripts for the next release. Once the update is out, it would be easier to post some step by step instructions. Hope the wait won’t be an inconvenience.


    Thanks Litwin, an improved sniper system is in the works. A dynamic crosshair is a good suggestion too! In the meantime, you might want to experiment with linking the scale of the crosshair GUITexture with the shotSpreadAmt var of WeaponBehavior.cs, which modifies weapon accuracy under certain conditions like sustained fire and zooming.

    We would also like to add vehicle physics at some point, as it is really just a matter of seamlessly transitioning/deactivating the FPS input and effects to vehicle related ones and parenting the main camera to the vehicle object. We will definitely keep you updated on our progress.
     
  33. Litwin

    Litwin

    Joined:
    Aug 15, 2013
    Posts:
    70
    @Azuline Studios
    Very good. I am very eager to see new updates. :)

    Another thing missing is the grenade.
     
  34. MaartenDEV

    MaartenDEV

    Joined:
    Sep 26, 2013
    Posts:
    11
    Thanks @Azuline Studios
    Just one more request :)P), could you maybe add a hitmarker when you hit an object with a CharacterDamage script? It'd really help me out here :)
     
  35. NessimOnair

    NessimOnair

    Joined:
    Jul 19, 2013
    Posts:
    22
    @Azuline Hii

    I want to know how to add the entire body to create a prefab player multiplayer games I already create my script multi etc. I miss her :/
     
  36. Eyehawk

    Eyehawk

    Joined:
    Dec 24, 2012
    Posts:
    288
    Hi Azuline, I recently got RFPS going with virtual joysticks. Basic movement seems to be fine, but I was just wondering, how do I get the walk-bobbing and footsteps to work with it?
     
  37. Deleted User

    Deleted User

    Guest

    Thanks Litwin, grenades won’t be in the upcoming update, but they will be added soon. Version 1.17 included the explosion code, all that’s needed now is setting up the weapon and animations :)


    Sure MaartenDEV, that’s a good suggestion. The more visual feedback the player sees, the better. We’ll add an option for hitmarkers in a future update.


    Nice work creating your own script NessimOnair! A thirdperson mode will be added soon. Sorry that we don’t have a step-by-step guide on how to add it yourself, but this post discusses the basic idea that might help get you started. Hope the wait for our implementation won’t be an inconvenience.


    Hi Eyehawk, if you access Unity’s built-in Horizontal and Vertical axes for the virtual joysticks and check the Use Axis Input var of the FPSPlayer.cs component, the footsteps and bobbing effects should play and scale with how far the joystick is moved. If you needed to use your own input method, then you could do a search in the scripts for where the useAxisInput var is checked and swap it out for a different one that reads your joystick method/axis. If you still need help with this, please let us know.
     
  38. Lights10

    Lights10

    Joined:
    May 10, 2013
    Posts:
    1
    Hello Azuline Studios,
    Do you have a time frame for when the next update will be released, and what new features it will include? Thanks.
     
  39. BuildABurgerBurg

    BuildABurgerBurg

    Joined:
    Nov 5, 2012
    Posts:
    566
    Hello Azuline Studios,

    I have been thinking about what you said about having FPS mode with arms animation showing only and then in 3PS mode showing the mecanim animations. Well I don't think it's the ideal way to do it, here are the reasons why.

    1: Reflections in FPS mode issue... When in FPS mode you won't be able to see your reflection in windows, water, mirrors. Just the hands would be reflected

    2: Multi-body colliders . I think more and more people want to see FPS becoming more realistic in this area. I would think that being able to shoot someone in different parts of the body and seeing the effect it has on that characters animation would make FPS more interesting, and because of mecanim re targeting system this makes it less time consuming to create. But as it stands you are going to just have one big collider when in fps mode.

    3: Bloated! Having both animation systems attached to the character is going to make it bloated. Also there are many tools and software for making rigged animated characters, but there aren't any for making fps hand animation so you will have to waste a lot of time using tedious methods to make hand animations. So every time you make an mecanim animation you will have to make FPS mode hands animation.

    I think if you just had the mecanim animation system and scraped the whole hand system it would solve all of these issues.

    Now I know I'm a noob at making FPS games and you guys are the Pro's, so I hope you are not offended and could just explain the positives of keep hand animation system in the next update.

    I can't think of any positives.

    I was thinking well maybe for memory reasons, but then even if you deactivate the the mecanim animation whilst in FPS mode it will still remain in memory.

    By the way I still consider this package to be my favorite FPS kit on the asset store :)
     
  40. thedreamer

    thedreamer

    Joined:
    May 13, 2013
    Posts:
    226
    I want the player to be automatically moving
    so I get the player to move on a preset path.

    Of course I want to keep the feeling of walking(or running)

    Do you think a good way?
     
  41. Deleted User

    Deleted User

    Guest

    Hi Lights10, all the features are complete for the next version and are undergoing testing. The next version is more of a technical/fine tuning update, but there are still some major improvements over 1.17. The upcoming update will probably be ready in a week or two. Here's the list of the changes:

    • Removed animation check var in CameraKick.cs to prevent rare occurrences of camera being 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 smoothing to sprinting animation playback for better motion transition.
    • Fixed playerHeightMod values between 1.0 and 2.0 not allowing player to move.
    • 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.
    • Optimized shotgun impact particle effects played on NPCs.
    • Improved timing of ejected shell rotation.
    • Added options for hiding weapon when player is underwater or holding an object.
    • Added inaccuracy var to NPCAttack.cs to allow enemies to miss on their attacks.
    • Made automatic weapon's recoil spread recover when the fire button is released instead of waiting for semi auto shot timer.
    • Added optional player hunger and thirst attributes which are reduced by apple and canteen pickups
    • Updated uncrouching obstacle check to prevent player from uncrouching into overhead geometry in some situations.
    • Hard-coded the raycast slope limit angle in FPSRigidBodyWalker.cs to 60 to prevent player from getting stuck in small indents or tight spaces (the capsule check slope limit can still be customized).
    • Scripts now prevent dragging objects while player is zoomed or dead.
    • Added kick back amount variables to WeaponBehavior.cs to allow slight backward motion of weapon during sustained fire.
    • Weapon z position (forward back) for zoomed, unzoomed, and sprinting states are now customizable from the inspector.
    • Added removePrefabRoot bool to WorldRecenter.cs script and deleted RemovePrefabRoot.cs script to allow option for keeping the FPS Main prefab root object or deleting it on scene load to allow the world recenter script to keep the FPS Player object's local and world coordinates synchronized to prevent spatial jitter and allow larger scenes.
    • Converted AI scripts from javascript to C# to allow easier compilation for android and windows projects and better communication between scripts.
    • Added walkBobAmountX and walkBobAmountY vars to WeaponBehavior.cs for customization of walking bob amounts per weapon.
    • Added walkBobYawAmount, CrouchBobYawAmount, ZoomBobYawAmount, and SprintBobYawAmount vars to Ironsights.cs to allow camera yaw angle bobbing.
    • Changed SendMessage call for ApplyDamage() functions to direct function calls identified by game object layer.
    • The sprintRegenWait and sprintRegenTime variables of FPSRigidbodyWalker.cs can now be used to disable the sprinting button until sprintRegenTime has elapsed and sprinting stamina is fully regenerated.


    You make some good points MoHoe and we appreciate the feedback. We are in the research phase right now of finding the best way to animate the player's thirdperson model. Based on some user requests, we'd like to maintain compatibility with Unity 3.5, which doesn't have Mecanim, so to start, we are considering using crossfaded animations of the player model in third person mode, and swapping out or disabling the player model's arms and head while in first person and using the current weapon models and player arms. We would also focus on making the script that animates the player model as independent of the other scripts as possible. Most of the movement and gameplay states already exist as accessible variables and the script would only have to read those vars to play the appropriate animations.

    We'd like to keep the current weapon model system because a lot of the code for the player prefab involves positioning and animating the hand models in a way that is similar to a mainstream FPS. There are many subtleties in the weapon model handling that, we think, contributes to the consistency and feel of player movement and actions. The additional memory for the thirdperson model would be comparable to adding another NPC type to the scene, so it's not too bad.

    Another reason for having the first person arm/weapon models separate from the third person ones, is to allow the player model to have lower fidelity (for rendering efficiency) which wouldn't be as noticeable in third person, but would be in first person.

    I agree that your idea of only using a Mecanim character without any separate FPS arm/weapon models, would be ideal, especially for multi-collider hit detection. Technology is getting to the point where traditional resource-saving techniques like I described above are becoming less necessary. We haven't decided on a particular method yet, as more testing is needed, but we welcome any input or ideas you might have.


    Hi thedreamer, to have the player move on a preset path, you could deactivate player movement input, manually activate the bobbing effect movement vars (so the bob cycle will play even if no movement buttons are pressed), and have the player follow a spline curve, like the one here on the community wiki. To implement this feature, there would be some work involved and study of our scripts, but hopefully this will give you some ideas.
     
  42. KingofMk98

    KingofMk98

    Joined:
    Oct 10, 2013
    Posts:
    63
    Azuline Studios how do i go about changing the Health and Ammo text to my own graphics? Newer to unity so i dont know to much and cant figure it out. Oh and one more thing. How do i make it so when my character walks into a fire he slowly loses health
     
    Last edited: Oct 10, 2013
  43. MaartenUT

    MaartenUT

    Joined:
    Aug 21, 2013
    Posts:
    18
    Hey KingofMk98 :) I know that your comment was meant for Azuline Studios, but I'd like to help too :)
    Now, I don't know how to change the graphics, but I do know how to apply damage to the character when he walks trough a fire:
    See, I've made a script myself for healing the player, so I think this will work:
    On the object/particles you use for the fire, add a box collider (component/physics/box collider) and be sure to check the "Is trigger" box.
    After that, create a new script with this in it:
    Code (csharp):
    1. private var inTrigger:boolean;
    2.  
    3. private var Player:GameObject;
    4. private var visible:boolean = true;
    5.  
    6.  
    7.  
    8. function Start () {
    9.  
    10. }
    11.  
    12. function Update () {
    13.  
    14.    
    15.  
    16.     if (inTrigger.Equals(true)) {
    17.    
    18.    
    19.         Player.GetComponent("FPSPlayer").SendMessage("ApplyDamage", 0.4);
    20.        
    21.        
    22.         }
    23.         TotalKitHealth -= 0.4;
    24.    
    25.     }
    26.    
    27.  
    28.    
    29.    
    30.  
    31.  
    32. }
    33.  
    34. function OnTriggerEnter (other : Collider)
    35. {
    36.     Player = other.gameObject;
    37.  
    38.   if(other.gameObject.GetComponent("FPSPlayer")){
    39.    
    40.  
    41.    
    42.     inTrigger = true;
    43.  
    44.  
    45.   }
    46.  
    47.  
    48. }
    49.  
    50. function OnTriggerExit (other : Collider)
    51. {
    52.     if(other.gameObject.tag == "Player"){
    53.  
    54.    
    55.     inTrigger = false;
    56.  
    57.  
    58.   }
    59.  
    60.  
    61.  
    62. }
    Be sure to check if the box collider only surrounds the fire, otherwise it would feel a bit unrealistic ;)

    PS: I don't know if this is the amount of damage you want to add per frame, but this is just an example :)


    And for people who want to add a health kit or something like that, do the same as what I just said, but then with this script:
    Code (csharp):
    1. private var inTrigger:boolean;
    2.  
    3. private var Player:GameObject;
    4. private var visible:boolean = true;
    5.  
    6. public var TotalKitHealth:float = 200;
    7.  
    8. function Start () {
    9.  
    10. }
    11.  
    12. function Update () {
    13.  
    14.     if (visible) {
    15.  
    16.     if (inTrigger.Equals(true)) {
    17.    
    18.     if (TotalKitHealth >= 0) {
    19.         Player.GetComponent("FPSPlayer").SendMessage("HealPlayer", 0.4);
    20.         } else {
    21.        
    22.        
    23.         renderer.enabled = false;
    24.         visible = false;
    25.        
    26.        
    27.         }
    28.         TotalKitHealth -= 0.4;
    29.    
    30.     }
    31.    
    32.     }
    33.    
    34.  
    35.  
    36. }
    37.  
    38. function OnTriggerEnter (other : Collider)
    39. {
    40.     Player = other.gameObject;
    41.  
    42.   if(other.gameObject.GetComponent("FPSPlayer")){
    43.    
    44.  
    45.    
    46.     inTrigger = true;
    47.  
    48.  
    49.   }
    50.  
    51.  
    52. }
    53.  
    54. function OnTriggerExit (other : Collider)
    55. {
    56.     if(other.gameObject.tag == "Player"){
    57.  
    58.    
    59.     inTrigger = false;
    60.  
    61.  
    62.   }
    63.  
    64.  
    65.  
    66. }
    It adds a limited amount of applyable health to the kit ;)
     
  44. KingofMk98

    KingofMk98

    Joined:
    Oct 10, 2013
    Posts:
    63
    @MaartenUT Thanks for the answer! but i get this error with the first script you posted
    BCE0044: expecting EOF, found '}'.
     
  45. MaartenUT

    MaartenUT

    Joined:
    Aug 21, 2013
    Posts:
    18
    Oops, sorry. Remove the } after TotalKitHealth -= 0.4; :)
     
  46. KingofMk98

    KingofMk98

    Joined:
    Oct 10, 2013
    Posts:
    63
    alright thanks but another error. Sorry if im doing something wrong. its a java script right?
    BCE0005: Unknown identifier: 'TotalKitHealth'.
     
  47. MaartenUT

    MaartenUT

    Joined:
    Aug 21, 2013
    Posts:
    18
    Oh sorry, I just edited it in here to make it applicable for fire, anyhow, remove the full TotalKitHealth -= 0.4; line, and you should be all set :)
     
  48. KingofMk98

    KingofMk98

    Joined:
    Oct 10, 2013
    Posts:
    63
    @MaartenUT It works great! thank you very much. One thing i'd like to ask though. the hurt effect is very strong when i step in. It covers the whole screen and i can see. is there a way to make the effect less, if not i can live with it. thanks again!
     
  49. MaartenUT

    MaartenUT

    Joined:
    Aug 21, 2013
    Posts:
    18
    I don't really know, that's probably because the script keeps applying damage. That's a question for @Azuline Studios ;)

    EDIT: Okay I might have an idea, wait a second
     
    Last edited: Oct 10, 2013
  50. MaartenUT

    MaartenUT

    Joined:
    Aug 21, 2013
    Posts:
    18
    Alright sorry for the long wait, I've been busy with something else :) This should fix the pain kick problem:
    Code (csharp):
    1. private var inTrigger:boolean;
    2.  
    3.  
    4.  
    5. private var Player:GameObject;
    6.  
    7. private var visible:boolean = true;
    8.  
    9.  
    10.  
    11.  
    12.  
    13.  
    14.  
    15. function Start () {
    16.  
    17.  
    18.  
    19. }
    20.  
    21.  
    22.  
    23. function Update () {
    24.  
    25.  
    26.  
    27.    
    28.  
    29.  
    30.  
    31.     if (inTrigger.Equals(true)) {
    32.  
    33.    
    34.  
    35.    
    36.  
    37.      //   Player.GetComponent("FPSPlayer").SendMessage("ApplyDamage", 0.4);
    38.  
    39.        
    40.  
    41.        
    42.  
    43.         }
    44.  
    45.  
    46. }
    47.  
    48.  
    49.  
    50. function OnTriggerEnter (other : Collider)
    51.  
    52. {
    53.  
    54.     Player = other.gameObject;
    55.  
    56.  
    57.  
    58.   if(other.gameObject.GetComponent("FPSPlayer")){
    59.  
    60.     inTrigger = true;
    61.     StartDamage();
    62.  
    63.  
    64.    
    65.  
    66.    
    67.  
    68.  
    69.  
    70.  
    71.  
    72.   }
    73.  
    74.  
    75.  
    76.  
    77.  
    78. }
    79.  
    80. function DoDamage() {
    81. StartDamage();
    82. }
    83.  
    84. function StartDamage() {
    85.  
    86.  
    87.     if (inTrigger.Equals(true)) {
    88.    
    89.     Player.GetComponent("FPSPlayer").SendMessage("ApplyDamage", 5);
    90.     yield WaitForSeconds(1);
    91.     DoDamage();
    92.    
    93.     }
    94.  
    95.  
    96. }
    97.  
    98.  
    99. function OnTriggerExit (other : Collider)
    100.  
    101. {
    102.  
    103.     if(other.gameObject.tag == "Player"){
    104.  
    105.  
    106.  
    107.    
    108.  
    109.     inTrigger = false;
    110.  
    111.  
    112.  
    113.  
    114.  
    115.   }
    116.  
    117.  
    118.  
    119.  
    120.  
    121.  
    122.  
    123. }