Search Unity

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

FPS Kit | Version 2.0

Discussion in 'Assets and Asset Store' started by NSdesignGames, Oct 2, 2012.

  1. dreadt9

    dreadt9

    Joined:
    Jan 13, 2012
    Posts:
    143
    http://docs.unity3d.com/Documentation/ScriptReference/Renderer-isVisible.html

    Look at the last Paragraph:

    "Note that object is considered visible when it needs to be rendered in the scene. It might not be actually visible by any camera, but still need to be rendered for shadows for example. Also, when running in the editor, the scene view cameras will also cause this value to be true."
     
  2. AsgerR

    AsgerR

    Joined:
    Apr 27, 2012
    Posts:
    18
    I did this by using raycast. Not the most stable way to do it, but it's more economic from a coding perspective than checking if the player is within the spectrum of the camera. (little hint: cast a ray at all objects containing the tag "Remote" and ray hits, then draw the name and if the ray doesn't hit, then dont.)
     
  3. willemsenzo

    willemsenzo

    Joined:
    Nov 15, 2012
    Posts:
    585
    Thanks for the help guys. I haven't tried to build the game yet to see if it makes a difference but that will be my next step. If that doesn't work I will try to do this with a raycast.

    Edit: Ok making a build isn't the solution either haha. I will try it with a raycast I guess.
     
    Last edited: Dec 4, 2012
  4. Acolit

    Acolit

    Joined:
    Aug 13, 2012
    Posts:
    51
    Could you make it with Photon Server?
    it's may help much
     
  5. exgengames

    exgengames

    Joined:
    Aug 10, 2012
    Posts:
    31
    y have problem
    D:

    how to Fix ?
     
  6. dreadt9

    dreadt9

    Joined:
    Jan 13, 2012
    Posts:
    143
    Any way to make is so after jumping you have to wait 0.5 secounds before jumping again?
    I tried looking through FPSController but there were no input values or anything I could work with...

    Please help, Thanks
     
  7. NSdesignGames

    NSdesignGames

    Joined:
    Dec 29, 2010
    Posts:
    496
    Are you working with Unity 4, if so, have you downloaded new version of FPS Kit 2.0 that is compatible with it?
     
  8. NSdesignGames

    NSdesignGames

    Joined:
    Dec 29, 2010
    Posts:
    496
    Check script called FPSInput.js, it handle player controls
     
  9. dreadt9

    dreadt9

    Joined:
    Jan 13, 2012
    Posts:
    143
    Any chance there is a variable containing the number of kills a player has made?
    If not, how could I create one?
     
  10. AsgerR

    AsgerR

    Joined:
    Apr 27, 2012
    Posts:
    18
    There isn't any variable containing it. But you could make one by sending the same message as the whokilledwko script sends to a script containing the number of kills. You could make an array of a custom class containing name and killcount and then check if the name is equal to one of the names in the array and then do killCount++.

    Hope you understand this description else i can try to be more specific.
     
  11. exgengames

    exgengames

    Joined:
    Aug 10, 2012
    Posts:
    31
    Hi ! y have other problem y created my acount y photon and start

    map the buttons do nothing
     
  12. NSdesignGames

    NSdesignGames

    Joined:
    Dec 29, 2010
    Posts:
    496
    Thats because you working with older version of FPS Kit 2.0 that is not compatible with Unity 4. You can download latest version in Asset Store
     
  13. exgengames

    exgengames

    Joined:
    Aug 10, 2012
    Posts:
    31
    What Version of unity 3d y need to Run 1.2c
     
  14. NSdesignGames

    NSdesignGames

    Joined:
    Dec 29, 2010
    Posts:
    496
    Version 1.2c were made with Unity 3.5.6

    Latest version is 1.3, it is compatible with Unity 4
     
  15. exgengames

    exgengames

    Joined:
    Aug 10, 2012
    Posts:
    31
    Hi how to add Fall Damage

    and

    I found many bugs in multiplayer

    *animations bugs in weapons jump etc
    *weapons sound
    *lag bugs Very high Lag e,e my normal ping is 200 in this game is 600 or 800
     
  16. Trawk

    Trawk

    Joined:
    Dec 7, 2012
    Posts:
    4
    For animation bug you have to add the tag:

    Code (csharp):
    1. Remote
    to your project.
     
  17. exgengames

    exgengames

    Joined:
    Aug 10, 2012
    Posts:
    31
    ok ok y add this and the animations is normal how to implement Fall damage from

    fpswalker enhanced

    Code (csharp):
    1.  
    2. var walkSpeed = 6.0;
    3. var runSpeed = 11.0;
    4.  
    5. // If true, diagonal speed (when strafing + moving forward or back) can't exceed normal move speed; otherwise it's about 1.4 times faster
    6. var limitDiagonalSpeed = true;
    7.  
    8. // If checked, the run key toggles between running and walking. Otherwise player runs if the key is held down and walks otherwise
    9. // There must be a button set up in the Input Manager called "Run"
    10. var toggleRun = false;
    11.  
    12. var jumpSpeed = 8.0;
    13. var gravity = 20.0;
    14.  
    15. // Units that player can fall before a falling damage function is run. To disable, type "infinity" in the inspector
    16. var fallingDamageThreshold = 10.0;
    17.  
    18. // If the player ends up on a slope which is at least the Slope Limit as set on the character controller, then he will slide down
    19. var slideWhenOverSlopeLimit = false;
    20.  
    21. // If checked and the player is on an object tagged "Slide", he will slide down it regardless of the slope limit
    22. var slideOnTaggedObjects = false;
    23.  
    24. var slideSpeed = 12.0;
    25.  
    26. // If checked, then the player can change direction while in the air
    27. var airControl = false;
    28.  
    29. // Small amounts of this results in bumping when walking down slopes, but large amounts results in falling too fast
    30. var antiBumpFactor = .75;
    31.  
    32. // Player must be grounded for at least this many physics frames before being able to jump again; set to 0 to allow bunny hopping
    33. var antiBunnyHopFactor = 1;
    34.  
    35. private var moveDirection = Vector3.zero;
    36. private var grounded = false;
    37. private var controller : CharacterController;
    38. private var myTransform : Transform;
    39. private var speed : float;
    40. private var hit : RaycastHit;
    41. private var fallStartLevel : float;
    42. private var falling = false;
    43. private var slideLimit : float;
    44. private var rayDistance : float;
    45. private var contactPoint : Vector3;
    46. private var playerControl = false;
    47. private var jumpTimer : int;
    48.  
    49. function Start () {
    50.     controller = GetComponent(CharacterController);
    51.     myTransform = transform;
    52.     speed = walkSpeed;
    53.     rayDistance = controller.height * .5 + controller.radius;
    54.     slideLimit = controller.slopeLimit - .1;
    55.     jumpTimer = antiBunnyHopFactor;
    56.     oldPos = transform.position;
    57. }
    58.  
    59. function FixedUpdate() {
    60.     var inputX = Input.GetAxis("Horizontal");
    61.     var inputY = Input.GetAxis("Vertical");
    62.     // If both horizontal and vertical are used simultaneously, limit speed (if allowed), so the total doesn't exceed normal move speed
    63.     var inputModifyFactor = (inputX != 0.0  inputY != 0.0  limitDiagonalSpeed)? .7071 : 1.0;
    64.  
    65.     if (grounded) {
    66.         var sliding = false;
    67.         // See if surface immediately below should be slid down. We use this normally rather than a ControllerColliderHit point,
    68.         // because that interferes with step climbing amongst other annoyances
    69.         if (Physics.Raycast(myTransform.position, -Vector3.up, hit, rayDistance)) {
    70.             if (Vector3.Angle(hit.normal, Vector3.up) > slideLimit)
    71.                 sliding = true;
    72.         }
    73.         // However, just raycasting straight down from the center can fail when on steep slopes
    74.         // So if the above raycast didn't catch anything, raycast down from the stored ControllerColliderHit point instead
    75.         else {
    76.             Physics.Raycast(contactPoint + Vector3.up, -Vector3.up, hit);
    77.             if (Vector3.Angle(hit.normal, Vector3.up) > slideLimit)
    78.                 sliding = true;
    79.         }
    80.  
    81.         // If we were falling, and we fell a vertical distance greater than the threshold, run a falling damage routine
    82.         if (falling) {
    83.             falling = false;
    84.             if (myTransform.position.y < fallStartLevel - fallingDamageThreshold)
    85.                 FallingDamageAlert (fallStartLevel - myTransform.position.y);
    86.         }
    87.  
    88.         // If running isn't on a toggle, then use the appropriate speed depending on whether the run button is down
    89.         if (!toggleRun)
    90.             speed = Input.GetButton("Run")? runSpeed : walkSpeed;
    91.  
    92.         // If sliding (and it's allowed), or if we're on an object tagged "Slide", get a vector pointing down the slope we're on
    93.         if ( (sliding  slideWhenOverSlopeLimit) || (slideOnTaggedObjects  hit.collider.tag == "Slide") ) {
    94.             var hitNormal = hit.normal;
    95.             moveDirection = Vector3(hitNormal.x, -hitNormal.y, hitNormal.z);
    96.             Vector3.OrthoNormalize (hitNormal, moveDirection);
    97.             moveDirection *= slideSpeed;
    98.             playerControl = false;
    99.         }
    100.         // Otherwise recalculate moveDirection directly from axes, adding a bit of -y to avoid bumping down inclines
    101.         else {
    102.             moveDirection = Vector3(inputX * inputModifyFactor, -antiBumpFactor, inputY * inputModifyFactor);
    103.             moveDirection = myTransform.TransformDirection(moveDirection) * speed;
    104.             playerControl = true;
    105.         }
    106.  
    107.         // Jump! But only if the jump button has been released and player has been grounded for a given number of frames
    108.         if (!Input.GetButton("Jump"))
    109.             jumpTimer++;
    110.         else if (jumpTimer >= antiBunnyHopFactor) {
    111.             moveDirection.y = jumpSpeed;
    112.             jumpTimer = 0;
    113.         }
    114.     }
    115.     else {
    116.         // If we stepped over a cliff or something, set the height at which we started falling
    117.         if (!falling) {
    118.             falling = true;
    119.             fallStartLevel = myTransform.position.y;
    120.         }
    121.  
    122.         // If air control is allowed, check movement but don't touch the y component
    123.         if (airControl  playerControl) {
    124.             moveDirection.x = inputX * speed * inputModifyFactor;
    125.             moveDirection.z = inputY * speed * inputModifyFactor;
    126.             moveDirection = myTransform.TransformDirection(moveDirection);
    127.         }
    128.     }
    129.  
    130.     // Apply gravity
    131.     moveDirection.y -= gravity * Time.deltaTime;
    132.  
    133.     // Move the controller, and set grounded true or false depending on whether we're standing on something
    134.     grounded = (controller.Move(moveDirection * Time.deltaTime)  CollisionFlags.Below) != 0;
    135. }
    136.  
    137. function Update () {
    138.     // If the run button is set to toggle, then switch between walk/run speed. (We use Update for this...
    139.     // FixedUpdate is a poor place to use GetButtonDown, since it doesn't necessarily run every frame and can miss the event)
    140.     if (toggleRun  grounded  Input.GetButtonDown("Run"))
    141.         speed = (speed == walkSpeed? runSpeed : walkSpeed);
    142. }
    143.  
    144. // Store point that we're in contact with for use in FixedUpdate if needed
    145. function OnControllerColliderHit (hit : ControllerColliderHit) {
    146.     contactPoint = hit.point;
    147. }
    148.  
    149. // If falling damage occured, this is the place to do something about it. You can make the player
    150. // have hitpoints and remove some of them based on the distance fallen, add sound effects, etc.
    151. function FallingDamageAlert (fallDistance : float) {
    152.     Debug.Log ("Ouch! Fell " + fallDistance + " units!");  
    153. }
    154.  
    155. @script RequireComponent(CharacterController)
     
  18. dreadt9

    dreadt9

    Joined:
    Jan 13, 2012
    Posts:
    143
    What variable in what script could I use to find the player that killed you. Its so I can add a killcam. So I can find that variable and make a camera search for the gameobject with that name and make it my kill camera's target. So what variable could I use?


    Thanks
     
  19. Trawk

    Trawk

    Joined:
    Dec 7, 2012
    Posts:
    4
    So I'm trying to make it so player names don't show everywhere, and I saw some one recommended using a raycast, so I decided to use one.

    The thing is, the prefab NetworkPlayer is on the layer "Ignore Raycast", so you can't use raycast.

    So I changed the layer, and it messed up a bunch of stuff, like the way the player holds guns, animations, and other things...

    BUT, the player name appeared how it was suppose to... but obviously I couldn't keep it like that because it messed up a bunch of stuff.

    So if I can't use raycast, what do I do?
     
    Last edited: Dec 9, 2012
  20. AsgerR

    AsgerR

    Joined:
    Apr 27, 2012
    Posts:
    18
    I would recommend shooting the ray at the "Soldier" found under the network player. The reason i suggest this is because it's not layered as Ignore Raycast and that's the mesh that's being displayed when you look at other players.
     
  21. Trawk

    Trawk

    Joined:
    Dec 7, 2012
    Posts:
    4
    I tried this before, and it didn't work.


    Ill retry it right now though and see if it works.


    Edit: Still not working with trying Soldier. I don't get any errors or anything, just simply doesn't work.

    Here's what I've tried:
    Code (csharp):
    1. if(Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit)){
    2.                  if (hit.collider.gameObject.name == "Soldier"){
    Code (csharp):
    1. if(Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit)){
    2.                  if (hit.collider.gameObject.tag == "Body"){

    Code (csharp):
    1. if(Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit)){
    2.                  if (hit.collider.tag == "Body"){
     
    Last edited: Dec 10, 2012
  22. AsgerR

    AsgerR

    Joined:
    Apr 27, 2012
    Posts:
    18
    You have to do something like :
    Code (csharp):
    1. if(Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit)){
    2.                  if (hit.collider.tag == "Blood"){
    The reason why the things you've tried doesn't work is because the soldier doesn't contain either a rigged body or a collider. So what you need to do is shoot the ray at the hitboxes that registers when a bullet hits the soldier.
     
  23. Trawk

    Trawk

    Joined:
    Dec 7, 2012
    Posts:
    4
    Doing it this way would mean you have to shoot the player at least once before the name appears though, right?
     
  24. exgengames

    exgengames

    Joined:
    Aug 10, 2012
    Posts:
    31
    how to add fall damage variable ?


    how AI zombies is posible ?
     
  25. pimpin

    pimpin

    Joined:
    Nov 11, 2012
    Posts:
    6
    How the f do you add the weapon to the multiplayer?
     
  26. pimpin

    pimpin

    Joined:
    Nov 11, 2012
    Posts:
    6
    nvm figured it out you should really let peeps know what to do
     
  27. NSdesignGames

    NSdesignGames

    Joined:
    Dec 29, 2010
    Posts:
    496
  28. yunspace

    yunspace

    Joined:
    Nov 8, 2010
    Posts:
    41
    Just bought this the other night, pretty cool. Setting multi-player up with my existing Photon id was a breeze.

    Out of curiosity, is this framework supported for Mobile?
     
  29. DLGScript

    DLGScript

    Joined:
    Jul 15, 2012
    Posts:
    272
    how can i get the FPS Controller scripts?
     
  30. NSdesignGames

    NSdesignGames

    Joined:
    Dec 29, 2010
    Posts:
    496
    Hey, I am really not sure about mobile devices since I havent tested FPS Kit 2.0 there
    Most likely there will be couple of errors ( For example generic lists are not supported on mobile platform etc.)
     
  31. exgengames

    exgengames

    Joined:
    Aug 10, 2012
    Posts:
    31
    Hey, that is the tutorial to add New weapon width animations
     
  32. NSdesignGames

    NSdesignGames

    Joined:
    Dec 29, 2010
    Posts:
    496
    Hey, check front post fot tutorials and documentations
     
  33. Teio07

    Teio07

    Joined:
    Dec 17, 2012
    Posts:
    9
    i can't spawn with the fps kit version 2.0 of unity
    http://u3d.as/content/nsdesign-games/fp ... on-2-0/3sw

    i get this error : NullReferenceException: Object reference not set to an instance of an object
    MainMenu.Update () (at Assets/FPS Kit Version 2.0/_CustomAssets/Scripts/OtherScripts/MainMenu.js:35)

    please help!!!
     
  34. exgengames

    exgengames

    Joined:
    Aug 10, 2012
    Posts:
    31
    Ey ! what is the tutorial to Add in multiplayer New weapon not is setup new weapon tutorial D:



    please y need help to add new guns

    y have 9 animated arms + guns models D:
     
  35. NSdesignGames

    NSdesignGames

    Joined:
    Dec 29, 2010
    Posts:
    496
    Make sure your character prefab is inside folder called Resources. Also just double click on that error, it will bring you into part of script which contain this error. From what I see looks like some variable is not assigned.
     
    Last edited: Dec 23, 2012
  36. NSdesignGames

    NSdesignGames

    Joined:
    Dec 29, 2010
    Posts:
    496
    Check this tutorial http://www.mediafire.com/view/?0wysaw6wrfdq4ib
     
  37. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Hi,

    Do you have a solution to this trouble. The focus of the sniper is flattened.
     
  38. NSdesignGames

    NSdesignGames

    Joined:
    Dec 29, 2010
    Posts:
    496
    Hey, if you check this demo, select Sniper Rifle and Zoom you will see that scope ratio will be the same with any resolution, so yea that problem is fixed in FPS Kit 2.0
     
  39. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    This is exactly what I said to a member of our community who did not dare ask in this forum.
    Thx. ;)
     
    Last edited: Dec 25, 2012
  40. yunspace

    yunspace

    Joined:
    Nov 8, 2010
    Posts:
    41
    Is it possible to add a animation to the melee attack? Currently in multi-player, if one player is attacking with a knife, the model will appear to the other player as simply standing still.
     
  41. NSdesignGames

    NSdesignGames

    Joined:
    Dec 29, 2010
    Posts:
    496
    Hey, yea you can make your own melee animation and assign it as fire animation for multiplayer.
    Demo character dont have this animation, so it was replaces by Idle
     
  42. TB0Y298

    TB0Y298

    Joined:
    Dec 25, 2012
    Posts:
    59
    Hey i have it now, but i have some issues :(
    I need help, can you?
     
  43. CHHOST

    CHHOST

    Joined:
    Oct 1, 2012
    Posts:
    7
    can you help me with this issue please.

    how do i add weapons to such a list? cant find them nowhere:


    like i want the 2'nd deaghe to be a sniper etc.
     
  44. NSdesignGames

    NSdesignGames

    Joined:
    Dec 29, 2010
    Posts:
    496
    Just click on any element from that list and it will show you that object in Hierarchy view, than replace Deagle with any other weapon.
     
  45. CHHOST

    CHHOST

    Joined:
    Oct 1, 2012
    Posts:
    7
    i figured it out :p

    BTW im having issues in multiplayer, where i cant seem to aim. when i play on a multiplayer server myself there is no issue, but once a player joins the game i cant aim (right click)
     
  46. NSdesignGames

    NSdesignGames

    Joined:
    Dec 29, 2010
    Posts:
    496
    Make sure your project contain tag called - Remote
    Just open tag manager and add it there
     
  47. TB0Y298

    TB0Y298

    Joined:
    Dec 25, 2012
    Posts:
    59
    Hey.. Hello! i need help!
     
  48. NSdesignGames

    NSdesignGames

    Joined:
    Dec 29, 2010
    Posts:
    496
    How do you expect to get any help if you didn't even explain your problem?
     
  49. AaronVictoria

    AaronVictoria

    Joined:
    Aug 21, 2010
    Posts:
    176
    I sent you a PM.
     
  50. Pixmah

    Pixmah

    Joined:
    Jan 3, 2013
    Posts:
    45
    how can i add game modes like TEAM DEATHMATCH and with scoreboard kill and death when pressing a key ??? help please