Search Unity

Realistic FPS Prefab [RELEASED]

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

  1. Ghost_Interactive

    Ghost_Interactive

    Joined:
    Jul 8, 2015
    Posts:
    54
    Sorry ! i dont understad with the animator trigger
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Using the Animation view, you can create new animation clips in Unity. These animation clips can animate any property, such as the position or scale of your door object. Watch this tutorial to see an example of how to create an animated door. In that tutorial, the animator controller uses a Bool parameter. The script I provided above uses a Trigger parameter, so you'll have to set up your animator controller slightly differently. If you're not familiar with animator parameters, go through Unity's helpful Animation tutorials.

    Unity has another good tutorial, too: Animate Anything With Mecanim. It also covers doors.
     
  3. Ghost_Interactive

    Ghost_Interactive

    Joined:
    Jul 8, 2015
    Posts:
    54
    Thanks @TonyLi , its working very good results. need 2 things to fix.
    1. both anim plays 1st start at game then door close. (maybe i done something wrong)
    2. if i hold button a little longer door open then close again.
    if you need a video for cheak ... i can do that
    please advice
     
  4. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Create an empty state in your animator controller. (Right-click on the canvas > Create State > Empty.) Then set it as the default state. (Right-click on the state > Set As Layer Default State.) This will prevent the open animation from playing at start.

    Then inspect your animation clip and make sure Loop Time is unticked.

    I also made an update to the script. Please see the update in my previous post. This will handle the animator controller properly if your transition is coming from Any State instead of the default empty state.
     
  5. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    So do you want the door to only open, or to change its state (open/closed) when holding the button?
     
  6. Ghost_Interactive

    Ghost_Interactive

    Joined:
    Jul 8, 2015
    Posts:
    54
    open & close both if possible, you can see in video.. both anim are working fine..
    only i added one line on update before else (uislider ture)
    now only need to stop this anim to play at game start then its good to go..
    Thanks a lot for helping me !! one more Q, i ask you one time about dialog system.(not bought yet).
    should i need it now (cut scene) or when the all level & scripting finished.
    and what els can i do with this asset (saw a post it can SAVE ammo & weapons for next level)
     
  7. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Try unticking the toggle next to "Open" in the Parameters list.

    You can use it to save and load games as you mentioned, add quests/missions, and of course add conversations and barks to your NPCs. You can also combine it with SoumiDelRio's S-Inventory if you want a complete inventory system.

    When I'm working on a project, I prefer to get all the major assets (RFPS, Dialogue System, MiniMap, etc.) working together before I build levels and write my own scripts.
     
  8. Ghost_Interactive

    Ghost_Interactive

    Joined:
    Jul 8, 2015
    Posts:
    54
    Now its working Perfect as i wanted.Also added some new line. @TonyLi you are a life saver.
    Demo -
     
    llJIMBOBll and TonyLi like this.
  9. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Happy to help!
     
  10. javier11om

    javier11om

    Joined:
    Apr 27, 2014
    Posts:
    28
    I'm trying to use my own platform, but the player slides when I jump onto it.
    I copied the settings for the platform already implemented-
    Set the layer to world collision.
    Added Rigidbody and box collider
    I looked at the script for the platform mover and it doesn't have any code related to the player being on it just code on moving the transform. Any suggestions on what else I'm missing anybody?
     
  11. NeuroToxin-Studios

    NeuroToxin-Studios

    Joined:
    Dec 7, 2014
    Posts:
    68
    Hi guys,

    For my project I want the player to be able to drive, For this I have the Realistic Car Controller.

    The problem is every time I import the package it breaks the tags and layers that RFPS sets up, adding in the tags and layers manually does not fix the issue.

    Is there a way for me to import the Realistic Car Controller and be able to use it without breaking RFPS along the way?
    Cheers
     
  12. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    578
    Yeah, just import without importing any project settings, rcs will auto set tags, and you can manual set the layer thru the settings in their resource folder
     
  13. NeuroToxin-Studios

    NeuroToxin-Studios

    Joined:
    Dec 7, 2014
    Posts:
    68
    Hi Jim,

    Cheers for the quick response, I followed what you said and now am getting Input not defined errors (creating the inputs leads to more errors with no resolution).

    I am sorry to ask this (and feel kind of pathetic) but can you give me a step by step guide on getting RFPS and RCC working together please.
    Cheers
     
  14. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    578
    Oh sorry you prob just need to add Horizontal and Vertical to Input manager, just duplicate I think look x and look y and rename to Horizontal and Vertical.

    If you goto RCC Resources folder you should find some settings manager, or I think you can access thru Tools / RCC at the top.
     
  15. NeuroToxin-Studios

    NeuroToxin-Studios

    Joined:
    Dec 7, 2014
    Posts:
    68
    Hi Jim,

    I did what you said and added both of them, I also created a Vehicle layer and selected it in the RCC Settings, I have also added the RCC Enter Exit Player Script to the main camera of the RFPS Player.

    When I play the FPS Demo Scene with the RFPS Player I can walk over to the vehicles and get the "Press Return to Enter" Popup however pressing return does nothing but spam my console with this error


    Alongside these errors I also have these warnings that are coming from the component to the right, I am not sure what values should be entered there


    Sorry for continuously asking for help
     
  16. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    578

    Hey for the 2nd picture I found if I imported a few assets at a time it would corrupt some names and stuff. Best way I found was to import RCC into a new project and cut and paste the folder to your RFPS project.

    There's a few things you need to do first. [/IMG]

    This is for Vertical and Horizontal you will need to add into Input Manager,


    I made a demo package quick, it includes 2 scripts i made for enter and exit and all the prefabs your need to make it work, It doesn't include any RCC or RFPS scripts only prefabs.

    I only enabled the Move Camera script and change the Lean collider tag, I removed the Player tag

    I fixed some of the code in my scripts from a previous post, and this all works now with 0 errors.

    https://drive.google.com/file/d/0BwHnbBuRZU8kcV9mZUd1WGJiMXM/view?usp=sharing

    Also goto Tools, RCC, then asset settings, you can then change the inputs your choice, also your wanna change the two layers from Gun to Default or which ever layer your want for your cars. Also I unticked engine running at start..

    I did make further edits so that you didn't need to reference the Players objects manually but that was for a previous project and I dont have it anymore, but you can simple change the code so it auto finds the players components. :D

    You don't need to have a player model in car but you can add one if you like, also you don't need to manually set the get out location, it will auto do it, unless you want to specify the exit location yourself
     
    Last edited: Jun 27, 2016
  17. NeuroToxin-Studios

    NeuroToxin-Studios

    Joined:
    Dec 7, 2014
    Posts:
    68
    With your instructions and scripts it is working, thanks for helping me and providing scripts and the scene, I highly appreciate it.
    [Edit]
    How can I show the Speedometer UI while in the car? tried multiple layers with no luck, turning on telemetry works and I can see all the debug info but without it I see nothing
     
  18. llJIMBOBll

    llJIMBOBll

    Joined:
    Aug 23, 2014
    Posts:
    578
    If you open a demo scene from RCC and copy and paste the UI to your new scene, also on the RCC asset Settings found under Tools, RCC or RCC Resource Folder, your need to enable the UI from there too. It is enabled by default so you prob find it will work if you just copy the canvas UI from a RCC demo scene :D
     
  19. NeuroToxin-Studios

    NeuroToxin-Studios

    Joined:
    Dec 7, 2014
    Posts:
    68
    Yup that did the trick, one thing I did do though was add a UI variable to your car script so that when the player gets in the car the UI enables and then it disables when you leave, works well. Cheers for all your help mate I really do appreciate it
     
    llJIMBOBll likes this.
  20. Deleted User

    Deleted User

    Guest

    Hey guys, apologies for my absence from the forums, I've been recovering from the flu and setting up a new workstation and OS, which has resulted in some downtime. Sorry if you've written an email or message lately and haven't received a response. Will be catching up on the backlog soon, as I do my best to respond to everyone. Hope you've been enjoying the update!
     
  21. Ghost_Interactive

    Ghost_Interactive

    Joined:
    Jul 8, 2015
    Posts:
    54
    Good Morning, Everyone !
    #1.
    is it possible to make cinematic takedown kills like other games, i have a theory for script.
    " player enter NPC trigger > press a button > two ragdoll will active > animation play> damage to NPC"
    i am not good at scripting, need some one for help."
     
  22. Shebzuhov

    Shebzuhov

    Joined:
    Mar 15, 2016
    Posts:
    1
    Hello. You can tell in detail how to add new Ai ? I mean 3D model + animation.
     
  23. Ghost_Interactive

    Ghost_Interactive

    Joined:
    Jul 8, 2015
    Posts:
    54
    hello, @TonyLi ,

    A simple Q , is it possible to lock the cursor to NPC, when player see a npc cursor lock & when NPC dead cursor unlock.
     
  24. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Do you mean a target lock? If so, it may be a little complicated, and perhaps @Azuline Studios could provide some tips.
     
  25. TryHarder

    TryHarder

    Joined:
    Jan 1, 2013
    Posts:
    121
    Hello,

    Has anyone noticed if you use the torch and right click (Zoom) the torch turns off, but if using a Xbox controller and pull the left trigger (Zoom) it doesn't.

    I thought the two controls were the same, they both zoom ?
     
  26. DerDicke

    DerDicke

    Joined:
    Jun 30, 2015
    Posts:
    292
    Hi,
    your package looks nice.
    I want to use it in a non-shooter FirstPerson- game. So I need a sophisticated FP movement system and good interaction with the world but no weapons and no FP related stuff like player arms or legs. A few questions:

    1.) How easy is it to get rid of the shooter stuff, eg. player arms/legs/weapon meshes?
    2.) I experimented with the Unity FPController. On terrain the player can jump uphill every slope no matter how steep. Can your system avoid that?
    3.) On Unity FPController the player never slides down steep terrain. You can always walk. Is it possible to slide down automatically with RFPS depending on the slope?
    4.) Is it possible to have different footstep sounds for different surfaces?


    Thanks in advance!

    Cheers,
    Chris
     
  27. Takahama

    Takahama

    Joined:
    Feb 18, 2014
    Posts:
    169
    1: Too easy
    2: Yes
    3: Yes
    4: Its already in there
     
  28. zelgo

    zelgo

    Joined:
    Jun 26, 2016
    Posts:
    39
    hey I have a few questions about the asset as well

    in the demo the 3rd person model was always carrying an assault rifle no matter what. this can be seen in first person mode as well due to shadows. is this in the paid version? is it easy enough to fix yourself with scripts to change what weapon model is displayed?

    is there a function to put away your weapon? is punching supported?

    does anyone know if you can use MCS models with this? possibly after using the FPS mesh tool on it

    thanks
     
    Last edited: Jul 21, 2016
  29. JC_LEON

    JC_LEON

    Joined:
    May 20, 2014
    Posts:
    520
    hi is there a way to replace text ui for health , ammo , thirst etc with bars??

    I purchased energy bar toolkit but cannot manage to integrate them with rfps ..any hint?
     
  30. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Hormic likes this.
  31. JC_LEON

    JC_LEON

    Joined:
    May 20, 2014
    Posts:
    520
    thanks tonyLi, i tried the first link you posted i diddnt understand if i must replace the line

    private GUIText guiTextComponent;

    with

    private UnityEngine.UI.Slider slider; //[PixelCrushers] Our Unity UI healthbar.

    or simply add the line after the


    private GUIText guiTextComponent;

    and the same question for the other lines..
     
  32. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    You only need to add lines. Don't replace any lines.
     
  33. JC_LEON

    JC_LEON

    Joined:
    May 20, 2014
    Posts:
    520
    i added the lines and obviusly imported the bar from eneegy bar toolkit as described in its readme :

    created canvas
    added filled bar from UI-energy bar tookit
    moved the bar where i want into canvas to match my needs ..
    tested game but nothing happened.. enemies shoot to me and only the text ui decrease

    maybe i must put the filled bar /(renamed healthbar) into fps player script?
     
  34. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Here are the instructions for Energy Bar Toolkit:

    1. Add an energy bar named “Healthbar”.

    2. Edit HealthText.cs. In the variable section, add this line:
    Code (csharp):
    1. public bool showNegativeHP = true; // This line already exists.
    2. public EnergyBar energyBar; //<-- ADD THIS LINE.
    3. In the Start() section, add these lines:
    Code (csharp):
    1. var energyBarGO = GameObject.Find("Healthbar"); //<--ADD THIS.
    2. if (energyBarGO != null) energyBar = energyBarGO.GetComponent<EnergyBar>();//<--ADD THIS.
    4. In the Update method, add this line:
    Code (csharp):
    1. if (energyBar != null) energyBar.valueCurrent = (int)healthGui; //<--ADD THIS.
     
  35. Marcirazzo

    Marcirazzo

    Joined:
    Nov 27, 2015
    Posts:
    47
    I can not change the size of the player. It's impossible to manage together all the values of the cam, the capsule and the model.
     
    AntonioModer likes this.
  36. slava_pankratov

    slava_pankratov

    Joined:
    Jan 17, 2015
    Posts:
    47
    AntonioModer likes this.
  37. JC_LEON

    JC_LEON

    Joined:
    May 20, 2014
    Posts:
    520
    YES .I made exactly as you said but didnt worked for me..
     
  38. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    The name of the GameObject has to exactly match the name in GameObject.Find("Healthbar") -- in other words, the GameObject must be named "Healthbar" with exact spelling and case.

    If that doesn't help, are there any errors or warnings in the Console window?

    You can try adding some debug lines:

    In Start:
    Code (csharp):
    1. var energyBarGO = GameObject.Find("Healthbar");
    2. if (energyBarGO == null) Debug.LogError("Can't find GameObject named 'Healthbar'!"); //<--ADD THIS.
    3. (energyBarGO != null) energyBar = energyBarGO.GetComponent<EnergyBar>();
    4. if (energyBar == null) Debug.LogError("Can't find health EnergyBar!"); //<--ADD THIS.
     
  39. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    If you only need to make the first person player taller or shorter, there's a value you can set in the inspector. Don't try moving the camera itself, since RFPS moves it dynamically at runtime. I'm not near Unity right now, so I can't look up what the value is. Maybe someone else here remembers?

    You have to edit the FPSRigidbodyWalker script. It's hard-coded.
     
    Last edited: Jul 19, 2016
  40. JC_LEON

    JC_LEON

    Joined:
    May 20, 2014
    Posts:
    520

    now working many thanks... i dont know why before not working.. i closed unity and reopened it and worked..

    now..

    image share


    as you can see the health text gui continue to be displayed... how can i remove it??


    and

    how can i change even the thirst and hunger gui with bars??

    tried to copy/paste the line you posted above changing health with hunger but dont seems to work
     
    Last edited: Jul 18, 2016
  41. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Edit the prefab Assets/RFPSP/Objects/HUD/HealthText and its child (HealthText2). On both, disable the GUI Text component.

    You'll have to make similar changes to HungerText.cs and ThirstText.cs.
     
  42. JC_LEON

    JC_LEON

    Joined:
    May 20, 2014
    Posts:
    520
    tried but when i disable the gui text component my player dont take damage from enemies gun

    tried adding the lines into the appropriate script but i got some erorrs related to hungerBar object cannot be found
     
  43. slava_pankratov

    slava_pankratov

    Joined:
    Jan 17, 2015
    Posts:
    47
    Сan you tell more about parameter which responsible for this ? capsuleCastHeight and playerHeightMod do not help
     
  44. JC_LEON

    JC_LEON

    Joined:
    May 20, 2014
    Posts:
    520
    this is my modified hunger script
    Code (CSharp):
    1. //HealthText.cs by Azuline Studios© All Rights Reserved
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class HungerText : MonoBehaviour {
    6.     //draw hunger amount on screen
    7.     [HideInInspector]
    8.     public float hungerGui;
    9.     private float oldHungerGui = -512;
    10.     [Tooltip("Color of GUIText.")]
    11.     public Color textColor;
    12.     [Tooltip("Offset from total screen width to position GUIText.")]
    13.     public float horizontalOffset = 0.0425f;
    14.     [Tooltip("Offset from total screen height to position GUIText.")]
    15.     public float verticalOffset = 0.075f;
    16.     [Tooltip("Scaled GUIText size, relative to screen size.")]
    17.     public float fontScale = 0.032f;
    18.     private GUIText guiTextComponent;
    19.     private float oldWidth;//to track screen size change
    20.     public HungerBar hungerBar; //<-- ADD THIS LINE.
    21.    
    22.     void Start(){
    23.         var hungerBarGO = GameObject.Find("Hungerbar"); //<--ADD THIS.
    24.         if (hungerBarGO != null) hungerBar = ehungerBarGO.GetComponent<HungerBar>();//<--ADD THIS
    25.         guiTextComponent = GetComponent<GUIText>();
    26.         guiTextComponent.material.color = textColor;
    27.         guiTextComponent.fontSize = Mathf.RoundToInt(Screen.height * fontScale);
    28.         oldHungerGui = -512;
    29.         oldWidth = Screen.width;
    30.     }
    31.    
    32.     void Update (){
    33.         if (hungerBar != null) hungerBar.valueCurrent = (int)hungerGui; //<--ADD THIS.
    34.         //only update GUIText if value to be displayed has changed
    35.         if(hungerGui != oldHungerGui || oldWidth != Screen.width){
    36.             guiTextComponent.text = "Hunger : "+ hungerGui.ToString();
    37.             guiTextComponent.pixelOffset = new Vector2 (Screen.width * horizontalOffset, Screen.height * verticalOffset);
    38.             guiTextComponent.fontSize = Mathf.RoundToInt(Screen.height * fontScale);
    39.             oldWidth = Screen.width;
    40.             oldHungerGui = hungerGui;
    41.         }
    42.     }
    43.    
    44. }
    but i got these errors on console

    Assets/RFPSP/Scripts/HUD/HungerText.cs(20,16): error CS0246: The type or namespace name `HungerBar' could not be found. Are you missing a using directive or an assembly reference?
     
  45. Marcirazzo

    Marcirazzo

    Joined:
    Nov 27, 2015
    Posts:
    47
    I don't find this value .
     
  46. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Change this line:
    Code (csharp):
    1. public HungerBar hungerBar; //<-- ADD THIS LINE.
    to this:
    Code (csharp):
    1. public EnergyBar hungerBar; //<-- ADD THIS LINE.
    I'm not near Unity right now, but the docs say: "-playerHeightMod and crouchHeightPercentage in FPSRigidbodyWalker.cs will now control standing and crouching height of player."

    It's not a variable. It's an actual, hard-coded number in one of the methods, maybe the Update() or FixedUpdate() method, something like 0.2f * capsuleHeight. I'm just going by memory.
     
  47. Marcirazzo

    Marcirazzo

    Joined:
    Nov 27, 2015
    Posts:
    47
    These values have been deleted in the latest version of RFPS.
     
  48. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Sorry, I'm not near Unity now. Maybe someone else remembers or can look it up?
     
  49. JC_LEON

    JC_LEON

    Joined:
    May 20, 2014
    Posts:
    520
    nope

    now i got this error

    Assets/RFPSP/Scripts/HUD/HungerText.cs(20,16): error CS0246: The type or namespace name `Energybar' could not be found. Are you missing a using directive or an assembly reference?
     
  50. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,706
    Capital 'B': EnergyBar. :)