Search Unity

UFPS : Ultimate FPS [ RELEASED ]

Discussion in 'Assets and Asset Store' started by VisionPunk, Mar 9, 2012.

Thread Status:
Not open for further replies.
  1. Samsson

    Samsson

    Joined:
    Oct 12, 2010
    Posts:
    165
    Thanks a lot !

    I will certainly ask you more, our devs will bbe on this very soon.
     
  2. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Hello I am da bawss. Nice to see you here again :)

    Thanks for the awesome pic and link. This is definitely a possible future feature, something I'd like to do sooner or later.
    In the meantime, it's probably not too hard to implement a basic version yourself. See discussion in the following posts:

    http://forum.unity3d.com/threads/12...era-RELEASED?p=1011746&viewfull=1#post1011746
    http://forum.unity3d.com/threads/12...era-RELEASED?p=1013931&viewfull=1#post1013931
    http://forum.unity3d.com/threads/12...era-RELEASED?p=1019909&viewfull=1#post1019909

    Cheers

    /Cal
     
  3. ZJP

    ZJP

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

    Happy customer here. I've a question. How have you make the demo level?. From scratch or with a generator?
    Because this is exactly this sort of design that i looking for one of my project.

    JP
     
  4. PrimeDerektive

    PrimeDerektive

    Joined:
    Dec 13, 2009
    Posts:
    3,090
    While I think thats an awesome concept and feature, I doubt that can ever be done with a one-size-fits-all plugin that would allow you to swap the model out for a model that wasn't created, rigged and animated with that exact purpose in mind.
     
  5. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    I don't know, with Mecanim and its automatic animation retargeting and generic avatar setup, I think it might be possible.
     
  6. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    Exactly, that's what I was thinking when I posted that. With Mecanim in Unity 4 it should be possible. The real challenge is to implement a full body physics rig instead of just the hand.
     
  7. topofsteel

    topofsteel

    Joined:
    Dec 2, 2011
    Posts:
    999
    Thanks, here is what I have...

    Code (csharp):
    1.     void Update()
    2.     {
    3.         ...
    4.        
    5.         if (Input.GetMouseButtonUp(1))
    6.         {
    7.             Screen.lockCursor = !Screen.lockCursor;        
    8.             ControlLock();
    9.         }
    10.     }
    11.    
    12.     protected void ControlLock()
    13.     {      
    14.         if (Screen.lockCursor)
    15.         {
    16.             SetState("ControlFreeze", false);
    17.             SetState("Freeze", false);
    18.         }
    19.         else
    20.         {
    21.             SetState("ControlFreeze", true);
    22.             SetState("Freeze", true);
    23.         }
    24.     }
    But i'm having a little trouble getting lockCursor to start in the right state. I put this line in the Awake() 'Screen.lockCursor = true;' but it's unreliable and it takes a few clicks for the logic to catch up with it.
    Also, I love the states feature. Do you have a comprehensive list of all of the available values? Thanks.
     
  8. janpec

    janpec

    Joined:
    Jul 16, 2010
    Posts:
    3,520
    @I am da bawss I like how your posts are always so clean and right on topic. Full body should be very much possible with Mechanim i guess, the only problem could be if there would be ragdoll system used like in game you posted, in that case ragdoll colliders would still have to be manually added, and since most ragdoll systems are difficult to set up properly this could be quite of extra work.
     
  9. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Ok, try changing the code in your Update to this:

    Code (csharp):
    1.  
    2. if (Input.GetMouseButtonUp(1))
    3. {
    4.     m_Player.LockCursor = !m_Player.LockCursor;
    5.     ControlLock();
    6. }
    7.  
    Actually, there are no pre-programmed values. Only a few demo example ones. Let me explain: States are not hardcoded. They are 100% user defined. You basically save your component settings in preset files. Then you create new states that you name yourself, and each state is then associated with a text preset. When the state is enabled from script it will blend the values in the preset file with any other enabled state presets in realtime. This is what makes it so awesome ;) ... You only have to get familiar with saving presets and partial presets ("Save Tweaks"), and ofcourse with the state system. Then you can design your own pretty advanced state blending setups. See the States chapter on page 43 in the manual for detailed info
     
  10. mikfento

    mikfento

    Joined:
    Feb 2, 2010
    Posts:
    2
    First of all, LOVE UFPS! Works fantastic and is extremely useful!

    I have been trying to figure out how to make a 'fly state' for the player. I have tried different state settings, then realized I needed some way to tell the player to go up and down other than just jumping, and was able to program that change in, but now I can't seem to get 'gravity' turned off.

    When the player travels in an up direction....all is well. When you then travel in a down direction, it's very sensitive even with the gravity multiplier set to 0 via code. A tiny little tap on the down button and the player goes screaming into the ground! All of these changes have been made within the FPSController script.

    Any advice on where to start or what I'm missing?

    Thanks!
     
  11. topofsteel

    topofsteel

    Joined:
    Dec 2, 2011
    Posts:
    999
    The name `m_Player' does not exist in the current context (vp_FPSPlayer) and `vp_FPSPlayer' does not contain a definition for `lockCursor'. Any ideas, Thanks.
     
  12. mikfento

    mikfento

    Joined:
    Feb 2, 2010
    Posts:
    2
    Got it figured out! =)

    It's not ideal because I would rather modify the mouse clicks to control forward motion and direction in 'fly mode' but this will work.

    Basically, I added the move controls, and the movement to the "Apply speed" section of the Controller script. I failed to alter the MotorThrottle via the MotorAcceleration variable.

    Played around with the values a bit and it works very well!


    here us what those two statements look like:

    Code (csharp):
    1. // MY FLY
    2.        
    3.         if (m_MoveUp)
    4.             m_MotorThrottle += transform.TransformDirection(Vector3.up * (MotorAcceleration * 0.3f) * m_MoveFactor);
    5.        
    6.         if (m_MoveDown)
    7.             m_MotorThrottle += transform.TransformDirection(Vector3.down * (MotorAcceleration / 5.5f) * m_MoveFactor);
    Hopefully this will help anyone looking to get started at modifying.....I'm not much of a coder so.....I'm proud of myself!
     
  13. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Hello mikfento,

    I'm glad you like the asset, and that you figured out a solution :). I tried it out - feels quite cool.

    Cheers

    /Cal
     
  14. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Sorry if my response was unclear. I assumed you were implementing your changes in a class that had a pointer to a vp_FPSPlayer. This is how to do it from a new Monobehaviour script:

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class YourScript : MonoBehaviour
    6. {
    7.  
    8.     vp_FPSPlayer m_Player = null;
    9.  
    10.     void Start()
    11.     {
    12.         m_Player = transform.root.GetComponent<vp_FPSPlayer>();
    13.     }
    14.  
    15.     void Update()
    16.     {
    17.         if (Input.GetMouseButtonUp(1))
    18.         {
    19.             m_Player.LockCursor = !m_Player.LockCursor;
    20.             ControlLock();
    21.         }
    22.     }
    23.  
    24.     protected void ControlLock()
    25.     {      
    26.         if (Screen.lockCursor)
    27.         {
    28.             m_Player.SetState("ControlFreeze", false);
    29.             m_Player.SetState("Freeze", false);
    30.         }
    31.         else
    32.         {
    33.             m_Player.SetState("ControlFreeze", true);
    34.             m_Player.SetState("Freeze", true);
    35.         }
    36.     }
    37.  
    38. }
    39.  
    Note: that you will have to unbind whatever is currently bound to the right mouse button (quickie: comment out the line "InputZoom();" in vp_FPSPlayer.cs.

    You shouldn't be afraid to make heavy customization to vp_FPSPlayer.cs, or copy it and make your own version.

    Hope this helps

    /Cal
     
    Last edited: Sep 27, 2012
  15. Manmax75

    Manmax75

    Joined:
    Jun 13, 2011
    Posts:
    88
    Hi there! I bought this a few weeks ago, and have absolutely loved it!

    However, I've run into a problem. I have a system, where the character is parented to a room, and then this room is moved to another location on the map (essentially teleportation). Now this works perfectly fine. However, as soon as I rotate the room (if the room has a rotation value on any of it's axis other than zero) then the controller completely stuffs up, walks in the wrong directions (or at an angle) and at the wrong speeds.

    How may I go about fixing this?
     
  16. Many_Field

    Many_Field

    Joined:
    Sep 26, 2012
    Posts:
    9
    Hello

    I recently purchased your work, and I'm totally in love. The camera system and management of weapons is very special and allows good numbers of parameters. Respect

    But I have some questions :

    1 - Is it possible to have impact/decal different depending on the surface with a single bullet or something else ?
    2 - Is it possible to add an effect of penetration ?
    3 - The animation "reload and reload2" for the pistol does not work if the object "demo" is inactive. or if there are two pistol. a solution ?

    4 - Future improvements in the health / ammo will be the game?


    PS: Thanks for the solution of particles per tag.
    PS 2: Sorry for my english, it's not my original language. It is possible that a solution is given below.


    Cheers
     
  17. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Cool, thanks for buying :)

    Phew, that's hard to analyze without having a closer look at the project, but I added a section to the manual regarding teleportation in the latest version. See page 61 in Documentation.pdf. It discusses how to teleport the character with correct angles. Just a thought: perhaps you could try temporarily de-parenting the player from the room while moving / rotating the room, then add the player back? (use the method in the docs to move rotate the player in-room) ...

    Let me know if this helps.

    Cheers

    /Cal
     
  18. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Sweet, thanks :)

    This is not supported yet, but I'd like to do it at some point. You should be able to tag different surfaces for various materials: dirt, metal, wood, flesh etc. to spawn different decals and effects. Will probably do this at some point but don't know when.

    Yes, but it's not included out-of-the box so you may have to implement it yourself. I am not planning to include this feature because it's a very genre specific feature and I'm keeping the asset as generic as possible (see this explanation).

    But if you want to have a go at creating your own projectiles with bullet penetration mechanics, there is an excellent discussion on this topic here:
    http://answers.unity3d.com/questions/188421/bullet-penetration-mathmathics.html

    Some more info on the UFPS bullet feature to get you going: The shooting class works by simply spawning a Unity gameobject. So if you put a grenade model in the projectile slot and press fire it will spawn a grenade hovering in mid air. If the grenade has rigidbody physics applied it will fall down. If the grenade has a script that sets some velocity on it in its Awake method, it will fly away from the shooter in a desired direction. So you see it is very open ended and with a little C# scripting and knowledge of the Unity scripting methods you can do pretty much what you want.

    The included bullet class uses hitscan / raycast physics like in classic DOOM, which means the bullet impact occurs instantly. If you want more realism you could modify the bullet script (or just create a new one) to spawn an actual model with physics on it and set velocity. The Ageia physics engine in Unity has some issues with tiny, fast moving projectiles not colliding properly, but I suspect there are quite a few forum threads discussing solutions to this (such as the one above).

    Yeah, that method is intentionally "hidden away" in the vp_FPSDemo2.cs script since it's not really the recommended way of doing more complex weapon animation. Quoting the method comment:

    "This is just an example of how you can play around with states and timers to create animations. NOTE: this is provided just as an example. It is not the recommended way of doing things: any complex animation such as a pistol reload sequence should be done using a regular animation on the pistol mesh. If you want this method in your actual game project (not really recommended), copy it into your player script along with its reference in 'Update'"

    I am not planning to flesh this out much more anytime soon. Even though I provide some helper classes for spawning projectiles and effects, Ultimate FPS Camera is little more than a camera and weapon system. I think it's up to each developer to decide how their health / death system should work. There are plenty of strategies.

    Hope this answers your questions !

    Cheers

    /Cal
     
    Last edited: Sep 28, 2012
  19. Many_Field

    Many_Field

    Joined:
    Sep 26, 2012
    Posts:
    9
    Thank you very much for your answers :).

    For additions expected by noobs (like me), do not it will be possible in the future to offer a complementary second pack it more oriented Fps-Kit and not Camera-kit ? (Purchasable course)

    Expect, I wish you a good continuation, your work is very wonderful, having tested FPS-Constructor although it is complete I will stay on your kit for its velocity and practicability. More I save "fps" per second that your build does not refuse ^^.


    Cheers
     
  20. reddotgames

    reddotgames

    Joined:
    Apr 5, 2011
    Posts:
    707
    My Horizontal Blur would be nice addon for all people that will buy your package :)
     
  21. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    The answer is yes, there is a fair chance I'll release more genre-specific separate products in the future.

    Cheers

    /Cal
     
  22. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    @reddot: Cool ! :)
     
  23. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    This week a couple of users asked me how to achieve a "progressive jump" instead of an "impulse" jump (basically like in Mario and Quake). This is what I came up with real quick:

    - Paste over the "InputJump" method in vp_FPSPlayer.cs with this code:

    Code (csharp):
    1.  
    2.     float maxJumpDuration = 10;
    3.     float softJumpForce = 0.45f;
    4.     float stopJumpTime = 0;
    5.     protected void InputJump()
    6.     {
    7.         if (Input.GetKeyDown(KeyCode.Space))
    8.         {
    9.             Controller.Jump();
    10.             if (Controller.CharacterController.isGrounded)
    11.                 stopJumpTime = Time.time + maxJumpDuration;
    12.         }
    13.         if (Input.GetKey(KeyCode.Space)  Time.time < stopJumpTime)
    14.             Controller.AddForce((Vector3.up * softJumpForce) * Time.deltaTime);
    15.         if (!Input.GetKey(KeyCode.Space))
    16.             stopJumpTime = 0.0f;
    17.     }
    18.  
    - Also, set the jump force on your FPSController to 0.1 (to reduce the initial impulse jump).
    - Now you have much greater control over the jump. When you jump, for as long as you press and hold the Space button the character will receive up force - but only for a limited time (maxJumpDuration), or until you release Space.
    - To regulate the force, tweak softJumpForce.
    - stopJumpTime is an internal variable that shouldn't be modified.

    Now, this is a hack and very untested code. It's probably buggy or choppy in some ways, but it might give you some ideas. I'll make sure to include a cleaner implementation in an upcoming release.

    Cheers

    /Cal
     
    Last edited: Oct 2, 2012
  24. topofsteel

    topofsteel

    Joined:
    Dec 2, 2011
    Posts:
    999
    Thanks for your help with locking the screen, very helpful!
    I would like to be able to switch between control schemes and also add move up to the control script. Can you give me a starting point. Thanks again.
     
  25. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Sure, I can tell you what I would have done :).

    For a control scheme solution, consider using cInput, an input manager for Unity. I actually haven't tried it myself yet but it looks very easy to set up. To use it in UFPS, you should just be able to change the "Input.GetKey" calls in vp_FPSPlayer to cInput's equivalent. I'm pretty sure you can do multiple control schemes in cInput but you'll have to ask them.

    For jet pack style solutions, the progressive jump example above is a good starting point. Also have a look at mikfento's solution.

    If you want an editor / godlike spectator cam (like Quake's "noclip"), create a new input method in vp_FPSPlayer and do something like the below.

    Code (csharp):
    1.  
    2.         float Speed = 8.0f;
    3.         Controller.collider.enabled = false;
    4.         if(CurrentWeaponID > 0)
    5.             Camera.SetWeapon(0);
    6.         if (Controller.PhysicsGravityModifier > 0.0f)
    7.         {
    8.             Controller.PhysicsGravityModifier = 0.0f;
    9.             Controller.Stop();
    10.         }
    11.         if (Input.GetKey(KeyCode.W))
    12.             Controller.transform.Translate(Controller.transform.InverseTransformDirection(Camera.transform.forward) * Speed * Time.deltaTime);
    13.         if (Input.GetKey(KeyCode.A))
    14.             Controller.transform.Translate(Controller.transform.InverseTransformDirection(Camera.transform.right) * -Speed * Time.deltaTime);
    15.         if (Input.GetKey(KeyCode.S))
    16.             Controller.transform.Translate(Controller.transform.InverseTransformDirection(Camera.transform.forward) * -Speed * Time.deltaTime);
    17.         if (Input.GetKey(KeyCode.D))
    18.             Controller.transform.Translate(Controller.transform.InverseTransformDirection(Camera.transform.right) * Speed * Time.deltaTime);
    19.  
    For a flying, in-world player with collision, you can instead do the following (it won't have gliding physics though).

    Code (csharp):
    1.  
    2.         if (Controller.PhysicsGravityModifier > 0.0f)
    3.         {
    4.             Controller.PhysicsGravityModifier = 0.0f;
    5.             Controller.Stop();
    6.         }
    7.         if (Input.GetKey(KeyCode.W))
    8.             Controller.CharacterController.Move(Camera.transform.forward * Speed * Time.deltaTime);
    9.         if (Input.GetKey(KeyCode.A))
    10.             Controller.CharacterController.Move(Camera.transform.right * -Speed * Time.deltaTime);
    11.         if (Input.GetKey(KeyCode.S))
    12.             Controller.CharacterController.Move(Camera.transform.forward * -Speed * Time.deltaTime);
    13.         if (Input.GetKey(KeyCode.D))
    14.             Controller.CharacterController.Move(Camera.transform.right * Speed * Time.deltaTime);
    15.  
    Hope this helps... I'll clean up and include a specator mode in the asset for a future release.

    /Cal
     
    Last edited: Oct 3, 2012
  26. x70x

    x70x

    Joined:
    Aug 20, 2011
    Posts:
    49
    Hey, I love what you've done here. It is saving me a lot of time on my project. I was just curious if there is a simple way to implement multiple "weapons". Basically, I have a helmet on my character setup as a weapon (similar to the mech example), but I want another weapon to be visible in front of the helmet that can be swapped at any time while the helmet stays in place (think Metroid Prime or Halo). Having both the helmet and the weapon be able to use their own bob and sway settings as well as not letting them clip through the environment would be my goal. The helmet would effectively never need to be swapped and could just stay there permanently.
     
  27. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Hey x70,

    This is not supported yet but will be in the not-too-distant future. If you can't wait, it shouldn't be all that hard to implement. The 'SetWeapon' and 'SwitchWeapon' methods work basically by hiding all weapon models and showing the one you used as an input parameter. I'm thinking it should be possible to edit the SetWeapon methods to accept two input weapons and activate two weapons instead of one. Now, I'm sure bugs and problems will surface and will have to be be dealt with but that's the jist.

    If you don't want to edit the core classes you can inherit from them and override the SetWeapon methods. Email me if you run into a wall :)

    Hope this helps

    /Cal
     
    Last edited: Oct 7, 2012
  28. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Ultimate FPS Camera v1.33 is now available in the Asset Store.

    This is just a compatibility update to get Ultimate FPS Camera ready for Unity 4. Also, the standard Unity methods (Start, Awake, Update etc.) of all the core classes have been made overridable. This allows you to create derived classes without changing the base classes (and risking overwrites when upgrading).

    For the full list of changes, see the RELEASE NOTES

    Cheers

    /Cal
     
    Last edited: Oct 8, 2012
  29. SevenBits

    SevenBits

    Joined:
    Dec 26, 2011
    Posts:
    1,953
    Cool. Nice job.
     
  30. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    Awesome! I'm glad you started the Unity 4 compatibility early; it makes my life a lot easier. :)
     
  31. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    Also, is there any info on how best to allow switching between 1st and 3rd person cameras? I imagine my players will mostly stay in 1st person mode, but I'd like to have a somewhat usable third person mode. I'm thinking of making the player model a child of the FPSPlayer object so that the movement control is shared, and having a separate camera using a follow script on the player, and disabling the Camera component of the FPSCamera and WeaponCame objects. I'm not sure how well the weapons will work if I do that though. Anyone have any experience with that?
     
  32. SevenBits

    SevenBits

    Joined:
    Dec 26, 2011
    Posts:
    1,953
    My personal advice? Modify the source code or code your own package. As for your approach, it might work, however you'd have to generously use culling to prevent artifacts.
     
  33. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Thanks guys, NP. I think we'll all benefit from it in the not-so-long term ;)

    @makeshiftwings: In case you hadn't noticed I added a couple of additional thoughts in your thread about this stuff.
     
  34. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    One more question... is there a way to have a recoil where the initial upwards recoil motion is slow? The way it currently seems to work is that the shot always snaps the gun to the max recoil position instantly, and then the Spring2 settings allow it to lower slowly. But I'd like a way to have the initial upwards motion slower as well (picture a really heavy launcher). I've been trying to Lerp the forces on the spring during recoil but haven't quite figured out how to get a slow recoil.
     
  35. miTriangle

    miTriangle

    Joined:
    Oct 10, 2012
    Posts:
    5
    This is first FPS plugin that are on almost same quality like in counter-strike.
     
  36. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Well, it doesn't "snap" per se (there is no target position). Rather the weapon gets a positional velocity impulse of user defined strength in a single frame, sending it a short distance very fast (probably in one or two frames) before the spring eases it back into the normal position.

    What you need can be done but you'll have to do some scripting. I suggest using the vp_Timer class to schedule several small force impulses to the weapon on the line after the Fire call (either that or expand the Fire method in vp_FPSShooter with the below feature).

    Assuming you're in vp_FPSPlayer, the syntax would be something like:

    Code (csharp):
    1.  
    2. vp_Timer.In(0, delegate()
    3. {
    4.         CurrentWeapon.AddForce2(Vector3.up * 0.3f, Vector3.zero);
    5. }, 20, 0.1f);
    6.  
    This would apply 20 positional impulses to the recoil spring with an up-force of 0.3, and an interval of 0.1 secs inbetween.
    I have no idea whether these values are any good - you'll have to tweak around. The idea is to have lots of tiny impulses firing in rapid succession for a limited amount of time.

    Note:
    • You can also use AddForce() to apply the force to the regular (swaying) spring.
    • The second vector is zero in this example but it's for rotation.
    • If you're in vp_FPSShooter, then 'CurrentWeapon' should be 'm_Weapon'.

    Hope this helps

    /Cal
     
    Last edited: Oct 10, 2012
  37. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    (sorry, didn't see this before) Yeah, as you say have a player model as a child to the FPSPlayer. You can easily offset the camera Z and Y position to well behind / slightly above the player using a different camera preset. Actually, the camera will try to stay outside of walls and other objects, much like in Tomb Raider, but it's not super-sophisticated and clipping will occur.

    Use the state system to switch between camera presets and make cool, smooth interpolations with a different FOV when the camera goes out of the player body. You'd have to hide the weapon in this mode ofcourse. If you want a rudimentary 3rd person mode this will work, but once you want it to be really awesome and smooth you will need to start rewriting / expanding camera code.
     
    Last edited: Oct 10, 2012
  38. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Hey thanks, miTriangle. I aim to please :)
     
  39. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    That's what I was trying, but the spring causes it to shake back and forth; it keeps trying to move back after each small impulse. Is there a way to temporarily turn the spring off?
     
  40. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Then I suspect your impulses are too few and far between. Also, you have 4 options: apply the impulses to either the regular weapon Spring (the one that's usually loose) or Spring2 (the recoil spring that's usually stiffer) plus you can add the force to either the positional or rotational vector of each.

    I assume you mean so that a Lerp or something could temporarily take control over the transform position? Maybe. I'm not sure off the top of my head what issues would arise. You would probably end up with quite a messy statemachine since it's working contrary to the rest of the system. I'm positive however that you can get what you want using AddForce / AddForce2. This is basically how all swaying motions on the weapon work (fall sway for example). But let me know if not.

    /Cal
     
    Last edited: Oct 10, 2012
  41. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    After messing with it for a while I got the effect I was looking for by temporarily lowering the Spring2's stiffness and damping to zero and applying a small force, like this:

    Code (csharp):
    1.  
    2. public void SlowForce2(Vector3 positional, Vector3 angular, float duration)
    3.     {
    4.         var currentPosStiffness = m_PositionSpring2.Stiffness;
    5.         var currentRotStiffness = m_RotationSpring2.Stiffness;
    6.         var currentPosDamp = m_PositionSpring2.Damping;
    7.         var currentRotDamp = m_RotationSpring2.Damping;
    8.         m_PositionSpring2.Stiffness = m_RotationSpring2.Stiffness = Vector3.zero;
    9.         m_PositionSpring2.Damping = m_RotationSpring2.Damping = Vector3.one;
    10.         AddForce2(positional, angular);
    11.         vp_Timer.In(duration, () =>
    12.                                   {
    13.                                       m_PositionSpring2.Stiffness = currentPosStiffness;
    14.                                       m_RotationSpring2.Stiffness = currentRotStiffness;
    15.                                       m_PositionSpring2.Damping = currentPosDamp;
    16.                                       m_RotationSpring2.Damping = currentRotDamp;
    17.                                   });
    18.     }
    19.  
    Thanks for the help! I appreciate how much support you give your customers. :)
     
  42. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    My pleasure. Cool solution you have there. Glad you got it to work.

    Cheers

    /Cal
     
  43. topofsteel

    topofsteel

    Joined:
    Dec 2, 2011
    Posts:
    999
  44. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Hmm, I'm not sure, but usually when there are rendering issues it has something to do with the dual camera setup. Try disabling the weapon camera object in your FPSPlayer and see what happens. It is possible to run Ultimate FPS Camera with only the main camera as discussed in previous posts, but you may have to deal with the weapon intersecting objects in a different way.
     
  45. MadToLove

    MadToLove

    Joined:
    Jul 22, 2012
    Posts:
    70
    Great product, was money well spent. I think it would be awesome to add some foot movement sounds and one thats built so when your walking on different materials or types of ground it can play different footstep sounds.
     
  46. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Yeah, This is something I've been planning to include for a while. It's in the pipe.
    Thanks for buying :)

    Cheers

    /Cal
     
  47. SevenBits

    SevenBits

    Joined:
    Dec 26, 2011
    Posts:
    1,953
    Yeah, yeah would be a cool feature to have for sure.
     
  48. smerf123

    smerf123

    Joined:
    Aug 26, 2011
    Posts:
    102
    How can I change the height of the crouch on the character controller? I need to go a bit lower. I found this in the script
    Code (csharp):
    1.     ///////////////////////////////////////////////////////////
    2.     // put player in the 'Crouch' state while holding 'C'.
    3.     // also: halve the height of the character controller so it
    4.     // makes a smaller target and may climb through smaller openings
    5.     ///////////////////////////////////////////////////////////
    6.     protected void InputCrouch()
    7.     {
    8.  
    9.         if (Input.GetKeyDown(KeyCode.C))
    10.             SetState("Crouch", true);
    11.  
    12.         if (Input.GetKeyUp(KeyCode.C))
    13.             SetState("Crouch", false);
    14.  
    15.         // update height of the character controller collision.
    16.         // NOTE: this must be kept up to date every frame or the
    17.         // character controller may fall through the ground
    18.         if (Controller.StateManager.IsEnabled("Crouch"))
    19.             Controller.Compact = true;
    20.         else
    21.             Controller.Compact = false;
    22.  
    23.     }
    24.  
    But I don't see no option to change the height!
     
  49. Cyrus_Zei

    Cyrus_Zei

    Joined:
    Apr 24, 2011
    Posts:
    41
    How hard is it to replace the maincamera that I have to this ?
     
  50. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Hello smerf,

    I assume you mean the height of the CharacterController collider and not the height of the FPSCamera when crouching (which is easy to change using a preset and the state manager). As you've noticed I've opted for a rather strict crouching solution that automatically snaps crouch height to half the normal height. There are two reasons for this:

    • The Unity CharacterController is very sensitive to runtime scale changes and will easily start falling through the ground.
    • If you change the CharacterController scale every frame (basically if you do smooth size changes) trigger detection will break and you will have triggers that don't fire when you run through them.
    I hope to make the crouching more flexible across future versions, as long as I can reliably keep it from falling through the ground and keep trigger detection from breaking.

    That said, below is a modification to "vp_FPSController.cs" that will be included in the next version and that gives you the ability to mod the crouching height. There is an important limitation though: Since the CharacterController uses a capsule collider, its height can never be smaller than its radius. If you want to make the height smaller than 0.5, you will have to reduce the radius too. In effect, the lower you want the collision, the more it will resemble a tiny ball :)

    1. In vp_FPSController.cs, at the top block of variable declarations, under "height", add the following two lines:

    Code (csharp):
    1.  
    2.     protected float m_NormalRadius = 0.0f;
    3.     protected float m_CompactRadius = 0.0f;
    4.  
    2. Replace the entire "vp_FPSController.Awake()" method with this:

    Code (csharp):
    1.     protected new void Awake()
    2.     {
    3.  
    4.         base.Awake();
    5.  
    6.         m_Controller = gameObject.GetComponent<CharacterController>();
    7.  
    8.         // store the initial CharacterController height for crouching logic.
    9.         // NOTE: we force the 'Center' parameter of the CharacterController
    10.         // to its 'Height' / 2 (placing its pivot point at the bottom),
    11.         // and its 'Radius' to the 'Height' / 4, otherwise the player may
    12.         // fall through the ground when crouching
    13.         m_NormalHeight = CharacterController.height;
    14.         CharacterController.center = m_NormalCenter = new Vector3(0, m_NormalHeight * 0.5f, 0);
    15.         CharacterController.radius = m_NormalRadius = m_NormalHeight * 0.25f;
    16.         m_CompactHeight = m_NormalHeight * 0.5f;    // <- reduce this to enable a lower crouch (but it can never go lower than 'm_CompactRadius')
    17.         m_CompactCenter = m_NormalCenter * 0.5f;
    18.         m_CompactRadius = m_NormalRadius * 0.5f;    // <- reduce this to enable a lower crouch
    19.  
    20.     }
    3. At the end of "vp_FPSController.Update()", in the two inner if-statements under "--- handle crouching ---", add this at the end of the first if-statement:

    Code (csharp):
    1.                 CharacterController.radius = m_CompactRadius;
    ... and this at the end of the second if-statement.

    Code (csharp):
    1.                 CharacterController.radius = m_NormalRadius;
    Hopefully this will solve your case. Please let me know if you run into any bugs with it.

    /Cal
     
    Last edited: Oct 22, 2012
Thread Status:
Not open for further replies.