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. hanso

    hanso

    Joined:
    Jun 18, 2012
    Posts:
    4
    ok, i have 2 questions left ;)

    1. How can i customize the controls. I have now a player without gun, and istead of shooting, i just want him to jump.
    right now, if i press the left mouse key / mouse 0 i get this error in the console:

    2. customize the crosshair? i didn't find anything about this in the documentation.

    thanks for any help!
     
  2. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    Hi!

    To customise the controls, look in the SimpleScript. This is where the controls are defined. Remove everything you do not need.

    Off the top of my head I cannot remember how to customise the crosshair, but if you check all of the components and see if one of them has one defined?
     
  3. smerf123

    smerf123

    Joined:
    Aug 26, 2011
    Posts:
    102
    Bump!
     
  4. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Sorry, as a rule of thumb I never announce dates, but I'm just back from a vacation and am now working on it daily in my spare time. I'll post a message here as soon as it has been submitted to the store.

    If you want a curved trajectory, you shouldn't use the vp_Bullet class. But remember that the vp_FPSShooter can eject any gameobject, just not vp_Bullets. You can put a teapot prefab in the slot and your machinegun will eject teapots. I haven't done tracer bullets before but perhaps you could make a prefab with an invisible mesh, rigidbody physics and a trail renderer applied to it? The gameobject's monobehaviour should apply its own velocity on Start. A word of warning though; I know that rigidbodies can act very unpredictably at high speeds. They may pass through other objects without registering a collision etc.

    Now, if you don't need the bullet to have a curved trajectory (you only want the tracer effect), you could edit the Start method of the vp_Bullet script and make it instantiate a moving game object with a trail renderer (and no rigidbody) in addition to the raycast. That'd be quite cool.
     
    Last edited: Jun 20, 2012
  5. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Hi smerf, This may be due to a certain bug that I and Nielo have been chasing. Do you mean that the gameobject+component hierarchy you created in the tutorial is completely intact after restarting unity but the weapon(s) do not fire? In that case, have a look at the Projectile->Prefab field of the weapon's vp_FPSShooter component. Does it say "None"? If so, try to reassign one of the "Bullet" prefabs into the slot. Save and see if it solved the problem.

    If it still doesn't work, try editing your vp_FPSShooter.cs file. Go to the RefreshSettings() method and add the following line after the first bracket:

    Code (csharp):
    1. m_NextAllowedFireTime = Time.time + ProjectileFiringRate;
    I'm very interested to see which of these solutions solves your problem (if any).

    Thanks,

    /Cal
     
    Last edited: Jun 20, 2012
  6. smerf123

    smerf123

    Joined:
    Aug 26, 2011
    Posts:
    102
    Thank's for the response,

    Under vp_FPSShooter component everything is correct, bullet, sound, shell. But they just don't fire, nor does the gun move with motion.
     
  7. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    Do you have the SimpleScript attached?
     
  8. smerf123

    smerf123

    Joined:
    Aug 26, 2011
    Posts:
    102
    I do yes. I also tryed using the SimpleScript 2 VisionPunk provided a couple of pages ago.
     
  9. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    Would you be able to package your scene up, and send it over via PM. I could take a look for you then.
     
  10. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Hi, here's a small update.

    I'm currently working on an advanced state system to handle an fps player's various states (Crouch, Run, Prone, Idle, Zoom, Injured, Leaning, Limping etc.) in a much more robust way with cleaner scripting. A new "FPSPlayer" class will be set up with good examples for a full, game ready player "preset rig" that handles input and switching between all the states.

    Also, a reload concept and a damage method on bullets.

    A number of additional features and bugfixes will be included (I'll confirm each when I know it's in for sure).

    Cheers

    /Cal
     
    Last edited: Jun 25, 2012
  11. kevdotbadger

    kevdotbadger

    Joined:
    Sep 13, 2011
    Posts:
    82
    Woah. Sounds great, look forward to it!
     
  12. IHave8Bosses

    IHave8Bosses

    Joined:
    Jun 14, 2012
    Posts:
    4
    Awesome asset, works perfectly and very user friendly. I have been able to incorporate some zombies and they take damage from the guns, but only the stock black dots. i tried incorporating the asset damage script from fps constructor, but nothing seems to work. i am trying to get them to take a couple hits, animate blood and then die. how can i incorporate the blood animation and damage without converting to fps constructor? any help greatly appreciated!
     
  13. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    (Regarding applying damage, there are previous posts on the subject in this thread.)

    For blood effects, here's a quick implementation idea:
    If you are a little versed in scripting you can edit vp_Bullet.cs, and around line 33 add an additional GameObject to hold your own blood particle effect prefab, like so:
    Code (csharp):
    1. public GameObject m_BloodPrefab = null;    // awesome blood particle effect
    Then, around line 105 add the following code:

    Code (csharp):
    1. // spawn blood particle fx
    2. if (hit.collider.tag == "Flesh")
    3. {
    4.     if (m_BloodPrefab != null)
    5.         Object.Instantiate(m_BloodPrefab, transform.position, transform.rotation);
    6. }
    7.  
    Then, assign a blood particle effect to all the Bullet prefabs in the inspector and make sure the colliders of your zombies have the "Flesh" tag. This is just an idea and not a full blown solution but it might get you started.
     
    Last edited: Jun 25, 2012
  14. IHave8Bosses

    IHave8Bosses

    Joined:
    Jun 14, 2012
    Posts:
    4
    thanks, must have missed it breezing through 13 pages. i will utilize search a little closer next time ;-)
     
  15. UnlimitedEdition

    UnlimitedEdition

    Joined:
    Feb 27, 2012
    Posts:
    287
    Definitely gonna buy once I get some more money.
     
  16. hxxhui

    hxxhui

    Joined:
    May 10, 2012
    Posts:
    9
    Hi, Cal:

    Thanks for your suggestion. I tried a few methods to show the trail bullet. The line render, tail render and rigidbody. It seems the tail render provide the best effect and performance, just as you indicated in the post.
    I instantiate a trailprefab in FPSShooter.cs right after the instantiation after bullet prefab, and set its postion and rotation ready, then move it.
    Code (csharp):
    1.  if (TrailPrefab != null)
    2.            {
    3.             GameObject q = null;
    4.             q = (GameObject) Object.Instantiate(TrailPrefab, m_MuzzleFlash.transform.position, m_Camera.transform.rotation);
    5.             q.transform.parent = m_MuzzleFlash.transform;
    6.         }
    A simple code attached to the trail prefab to make it move

    Code (csharp):
    1. void Update()
    2.     {  
    3.         transform.position += transform.forward * speed * Time.deltaTime;
    4.         Distance -= speed * Time.deltaTime;
    5.        
    6.         if (Distance < 0) {
    7.             Object.Destroy (gameObject);       
    8.         }
    9.     }
    The effect of bullet trail is fine, but one problem bothered me. When shooting while running, the begining point of the trail always behind the moving of gun. It looks like the bullet is shooting from someone beside me.
    i tried two ways to fix this:
    1. add the movment compensation:
    Code (csharp):
    1. q.transform.position += m_controller.velocity*ProjectileFiringRate
    2. Attach a firepoint gameobject to gunpoint and let it move together with the gun. then I use the gameobject position as the position of trail object .
    Ether ways above seems not the right solution.

    Any suggestion for this? 
    Thanks a lot
    谢谢
     
  17. hanso

    hanso

    Joined:
    Jun 18, 2012
    Posts:
    4
    hey guys. playing around with the fps camera is so much fun!
    If got 2 little question, about the movement:

    Is it possible to let my player do a walljump? something like, jumps to a wall, stick for minimum of time, then be able to jump off there again. (maybe possible with the wall bouncing?)

    Is there an easy way to implement a ledge hang? player jumps on a corner of a wall, camera is facing to the wall, player sticks to it, then pull-up by pressing the w "up" key?

    thanks for any help!
     
  18. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    @hxxhui: I did some testing to see if I could help you out with this.

    First off, where you do this:
    Code (csharp):
    1. q.transform.parent = m_MuzzleFlash.transform;
    I wouldn't assign the trail as a child to the muzzleflash. Instead you should "set it free" in the world, that is: don't parent it to anything. I got some very weird results using the muzzleflash as a parent.

    Your trail script seems fine to me. For you last code snippet:

    Code (csharp):
    1. q.transform.position += m_controller.velocity*ProjectileFiringRate
    This won't work very well. The projectile firing rate regulates how often a weapon can shoot and I don't see how it would be of any use here. I too did some testing applying the controller velocity to the transform position of the trail but couldn't come up with anything useful quickly. You should be able to find threads on this though (applying velocity of parent to a spawned projectile ) ...

    What I could get working decently (again, just a quick test) was this:

    Code (csharp):
    1. if (TrailPrefab != null)
    2. {
    3.         GameObject q = (GameObject)Object.Instantiate(TrailPrefab, m_MuzzleFlash.transform.position + m_Camera.transform.TransformDirection(new Vector3(0, 0, 5)), m_Camera.transform.rotation);
    4. }
    5.  
    Here, I spawn the trail 5 meters ahead of the player which makes the positional offset when moving less noticeable, and the trail still displays fine. Note: I used a trail script velocity of 200 and Trail Renderer parameters like so: Time=0.1, Start+End Width: 0.2. This gives a Star Wars / WW2 dogfight appearance. Short and fast trails.

    Speaking of player velocity, note that in my default scripts the player moves super fast, e.g. like in Quake 3. slowing down the character controller will have a considerable effect on trail displacement.

    One thing that occured to me is if you're doing this type of tracer bullets, you shouldn't spawn a trail on every shot fired since only every fifth round has a pyrotechnic charge. This can be easily achieved by introducing a counter in the shooter script and only spawning a trail every fifth shot. This is just if you're into military realism though (in which case you probably don't want raycast bullets anyway) ...

    Finally, I notice that the trail geometry appears very flat, especially when viewed from directly behind it. On second thought I would have used some other type of geometry if I were you, especially if you want the trails to be fast and short; then you don't really need the trail renderer and should be better off with a model with "thickness", and maybe an additive transparent shader.

    Hope this will be of some use to you.

    /Cal
     
    Last edited: Jun 28, 2012
  19. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Hi hanso,

    Yes it's most likely possible to do wall jumping and ledge climbing. I've never done any of these in Unity but I see there are quite a few threads discussing the topic (tip: google for unity wall jump). I don't think the wall bounce parameter is going to help you stick to the surface since it's doing rather the opposite: deflecting the player away from it (and it won't be useful when jumping away from the surface either since at that point the player is immobile and the wall bounce needs controller velocity to work). One thing you may be able to exploit is this:

    If you set the CharacterController (not the vp_FPSController but the Unity one) "Slope Limit" to 0, and the "Skin Width" to 0.01, the player will stick to any flat wall that has an ever so slight slope (i.e. put a huge cube in the level and rotate it very slightly, and you should be able to jump up the upward facing side. Raycasting into the wall upon key press and applying a force to the vp_FPSController away from the wall should do the trick after that.

    Beware though: the player will no longer be able to walk in terrain without jumping because of the Slope Limit and it may fall through the ground or get stuck at walls because of the Skin Width so it's super shaky, but you may be able to set these values only when jumping close to a wall, who knows :)

    I hope this will give you some ideas, but I still recommend researching the various wall jumping threads for a proper solution.

    Cheers

    /Cal
     
    Last edited: Jun 28, 2012
  20. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
    Is the movements based on Rigidbodies, CharacterController (the Unity/PhysX one) or done manually using raycasts? The same question for collision, how is it handled?

    I'm looking to use this for a multiplayer FPS, but unless deterministic (or at least less volatile then Rigidbody/Character Controller) movement is implement it will make it very hard to use with things like input prediction and rewinding/forwarding movement commands on the client/server.
     
  21. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Hi, The included controller uses the standard Unity CharacterController. On top of that it has a few relatively crude ways of applying external sliding forces and deflecting these away from colliders, dealing with slopes etc. Collision is handled by the CharacterController.

    If you're looking for an asset to improve upon Unity's built in controller/rigidbodies (in the area of networking) this is not the one. Its main focus is visual effects, i.e. the procedural motion of the camera and weapon, and this is where it really shines.

    That said, I'm sure you would be able to rip out the controller parts and put the camera and weapon classes to use with an enhanced controller. The question is how much time you're willing to spend :)
     
    Last edited: Jun 29, 2012
  22. MoradM

    MoradM

    Joined:
    Jun 28, 2012
    Posts:
    1
    I have to say, this is quite amazing.
    I'll buy it when I can afford!
     
  23. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711


    Done wrapping up the new layered state system. *phew* Downhill from here!

    Edit: This feature will basically allow you to mix presets at runtime with less need for scripting. It will merge and switch between full or partial presets in a very simple but powerful manner.

    It works kind of like layers in Photoshop. The state (layer) at the bottom represents the current inspector values of a component. The state above it represents a preset that will override all - or just some - of the underlying one's values, and so on up the list. If a state is disabled the remaining presets in the list will be smoothly recombined (let's say you release the Crouch key while still holding the Zoom key).

    State presets are loaded as text files at startup but reside in memory to be switched on or off at any time with no need to reload them. In summary, this allows for some crazy mixing of presets that previously required messy scripting. The presets blend quite beautifully and I've been having a blast with it today :)
     
    Last edited: Jun 30, 2012
  24. Alayna

    Alayna

    Joined:
    May 4, 2012
    Posts:
    4
    Will image effects not working be fixed in the next release, or does anyone have any mini-tutorials on how to get around the issue? The product is great and I'm very happy with it, but unfortunately i cannot use it without image effect support.
     
  25. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    I do hope to fix the image effects issue in this build.
    Can't promise anything before I've taken a closer look though.
     
  26. Mcg

    Mcg

    Joined:
    Mar 28, 2012
    Posts:
    112
    this is very polished , would you consider adding a multiplayer networking example?
     
  27. benswinbanks

    benswinbanks

    Joined:
    Apr 22, 2012
    Posts:
    11
    Hi there awesome setup!

    can you fix the code to work with correct inputs so I can use a gamepad setup? also, how can I fix it so my changes in the ispector wont reset every time i restart the game its so frustrating...


    thanks again
    Ben
     
  28. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Hi Mcg, Glad you like it! The main focus of this asset is camera motion and visual effects, although it also contains an extended character controller. I suggest checking out the Asset Store for multiplayer assets. If I delve into networking in the future I'll be happy to post my findings in this thread, but I'm not planning to do so anytime soon (sorry). I hear Photon networking has many Unity examples and walkthroughs. http://www.exitgames.com/Photon/Unity
     
    Last edited: Jul 3, 2012
  29. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Hi Ben, Gamepad support would be a good addition to the controller. I'll make a note of this. Can't tell you when though.

    Have you noticed the "Persist play mode changes ON / OFF" button? It may be what you are looking for. You may otherwise be experiencing a bug, or there may be some confusion regarding the fact that the examble FPSPlayer prefab overrides the inspector through the "SimpleScript" (!)

    I'm currently working hard to make this aspect of the system less confusing in the next version, but until then here's one of my previous forum answers to this question:

    The FPSPlayer prefab overrides all your changes when you press play. This is intended, and happens because the script attached to the controller inside it does load its own text file presets when you press play. In order to change this behavior. You need to either:

    1) Edit the SimpleScript.cs file so that it does not load any preset text files, or load the text files of your choice.
    ... or ...
    2) set up your own FPSPlayer from scratch with your own custom made player script (see instructions in the manual).

    ● However, I can definitely see why this is not very obvious. I have created a new "FPSPlayer2" prefab that does not load its own presets. Get it from here:
    http://www.visionpunk.com/misc/FPSPlayer2.unitypackage

    Once imported, there should be an "FPSPlayer2" in the "Prefabs" folder, and a new modified script "SimpleScript2.cs" in the UltimateFPSCamera root. Use the prefab instead of the regular one. It should allow you to make any changes to any component in the prefab, without them getting reset.

    ● Also keep in mind that the default Unity behavior is to reset all runtime inspector changes when you press Stop. To get around this, use the "Persist play mode changes -> ON" button.
     
  30. Mcg

    Mcg

    Joined:
    Mar 28, 2012
    Posts:
    112
    ok thanks was just curious , very happy with the puchase but just wondering what the scene with just the untextured terrain is for ? :p
     
  31. WolfoX

    WolfoX

    Guest

    I sent you a pm about it, but looks like this forum is all messed up after udn, so...

    Any chances on adding hands (gloves like in Crysis) with spell gestures, instead of only gun models?
    I have no interest in Fps, but something like this with hands (Sci-Fi gloves), I would blindly pay $100+.
     
    Last edited by a moderator: Jul 3, 2012
  32. Deleted User

    Deleted User

    Guest

    Just bought this asset and I'm having some bizarre problems. I dropped in the standard FPSPlayer prefab and disabled the revolver and machine gun children (so to just use the pistol). I'm trying to tweak the motion parameters but they don't save. I'd adjusted acceleration and damping all the way to 1, but when I run the game in the editor they reset back to 0.252 and 0.1 respectively. Any ideas why the component isn't saving any of my changes?

    Update: I've also tried changing some of the damping on the zoom animations which also aren't being saved. I'm using the latest 3.5.3f3 build of Unity, in case that makes any difference. :)
     
    Last edited by a moderator: Jul 4, 2012
  33. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Hi Nick, Yeah I answered this question quite exhaustively some two posts back in this thread. It's on the previous page though so I can see how you missed it :) There's just some confusion on how the default scripts override values for demo purposes. This is thoroughly addressed in the next version.
     
  34. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    (Wolfo, I've emailed you.)
     
  35. Deleted User

    Deleted User

    Guest

    Whoops. I tried looking through some of the posts and must've missed that one. I'll give that a shot and let you know if I have any issues.
     
  36. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Np, just let me know if you need help.

    /Cal
     
  37. Eqric

    Eqric

    Joined:
    Jun 29, 2012
    Posts:
    51
    I must say, this is the best product i have bought so far on the Unity store!
    It's very easy to modify to get the result you want and its well documented.
    Worth every cent!

    May i ask what comes in the next update?

    // Eric
     
  38. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Eric, I'm glad you like it!

    The features I do know for sure will be in the next update are discussed in these two posts:
    http://forum.unity3d.com/threads/126886-Ultimate-FPS-Camera-RELEASED?p=964997&viewfull=1#post964997
    http://forum.unity3d.com/threads/126886-Ultimate-FPS-Camera-RELEASED?p=970003&viewfull=1#post970003
    Plus an issue with image effects in Unity Pro that I have promised to take a look at.

    I'm not sure exactly when it will be done - It's actually a fairly big update from a technical standpoint, and requires lots of bugfixing and new documentation. But I'm working on it every day and it's starting to shape up now :)
     
  39. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Love this package so far. I've added ammo and reloading as well as damage to enemies and player. However, one thing still baffles me. How can I add/swap weapons at runtime? I've had no luck getting anything to work.

    Also, for some reason when I set up a save feature, every time it loaded, all weapons (plus one for the active one) and the pivots were visible. I was able to "fix" this by turning off the renderers just before save and back on when it is loaded. I am using the free Unity Serializer (from asset store) and set up to use a keystroke instead of mouse clicks to save/load, if you want to see for yourself.
     
  40. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Hi drew, Check out the "SwitchWeapon" method in Demoscript. It users timers to rotate the weapon out of view, set a new weapon, then rotate the new one in. That said, the new version I'm working on has a new cleaner fps player class that contains this functionality. I've implemented ammo and reloading too now but this is optional to use.

    Regarding the weapons and pivots showing, my guess is the main gameobject is being activated recursively, that is, all its children are being activated too. Try doing a 'SetWeapon' after loading to see if that fixes it.
     
  41. quydoau

    quydoau

    Joined:
    Jul 2, 2012
    Posts:
    31
    Hi, is there any plan to include firing bow and arrow?
     
  42. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Hi, quydoau (sorry for the delayed response). Yes, I'd very much like to do that. I think the system is suitable for it given the tactility of the spring physics. You could do lots with rotational recoil etc. It's definitely something I'd like to add in the future but it's not included at present.

    Cheers

    /Cal
     
  43. quydoau

    quydoau

    Joined:
    Jul 2, 2012
    Posts:
    31
    Your implementation of physic is amazing, it adds the reality factor to things, I look forward to future update. By the way I just bought it, keep up the good work.

    Cheers.
     
  44. Nanity

    Nanity

    Joined:
    Jul 6, 2012
    Posts:
    148

    It is so smooth... I'll definitly invest the 30$ if I'd be a proffessional programmer. I can't even imagine an approach to that *googles input smoothing*
     
  45. Eqric

    Eqric

    Joined:
    Jun 29, 2012
    Posts:
    51
    I am far from an professional programmer(2 years now) but i find his code very easy to understand, much thanks to the documentation.
    Done some modifications and added stuff to the system without much problem at all :)

    So what i wanted to tell is, its not that hard as you think thanks to the structure and the clean code :)
     
  46. Wrekk

    Wrekk

    Joined:
    Jul 16, 2012
    Posts:
    51
    When I try to use OnMouseEnter for highlighting an object, it just flickers. This only happens when the camera script is enabled.
    Any ideas how to fix this? :)
     
  47. azeitler

    azeitler

    Joined:
    May 14, 2008
    Posts:
    162
    Bought it because I liked the demo. Can't get it to work. FPS Camera jumps to something around (x,10000,10000) and stays fixed there, camera moves and rotates a bit but does so quite jerkily. What up?
    Do I need to setup specific layers in the project or specific input axis?
     
    Last edited: Jul 16, 2012
  48. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Hi Wrekk,

    I'll try to help out. A few questions:
    • Do you want to highlight the object by pointing at it with the FPS crosshair, or by putting the mouse pointer over it? When the FPS camera is enabled it uses Unity's 'screen.lockCursor', which means that the mouse is forced to stay center screen. See docs HERE
    • What method of highlighting are you using ? Do you change the shader or color of the object?
    • What OS and Unity version do you have? Are you using Unity Pro?

    /Cal
     
    Last edited: Jul 17, 2012
  49. VisionPunk

    VisionPunk

    Joined:
    Mar 9, 2012
    Posts:
    711
    Hi azeitler,

    The layers used by the system may be configured in the file "vp_Layer.cs". The inputs can be customized in the file "vp_SimpleScript.cs" (if you're using the FPSPlayer prefab).

    A couple of questions:
    • How do you go about starting the game? Have you opened the SimpleScene or the DemoLevel? Or have you dropped the FPSPlayer prefab in a scene / project of your own?
    • What OS and Unity version do you have? Are you using Unity Pro?

    Thanks

    /Cal
     
    Last edited: Jul 17, 2012
  50. WarpZone

    WarpZone

    Joined:
    Oct 29, 2007
    Posts:
    326
    Sorry but this is just a quick test to see if the forum is working or not. The last message I posted in this thread didn't show up. :(

    Edit: Awesome, seems to be working now.

    At line 105 in SimpleScript, replace the "handle shooting" section with the following:

    Code (csharp):
    1.  
    2.         // handle shooting
    3.         if (Input.GetMouseButton(0))
    4.         {
    5.             if(m_Camera.WeaponCount > 0){
    6.                 vp_FPSShooter shooter = m_Camera.CurrentWeapon.GetComponent<vp_FPSShooter>();
    7.                 if (shooter != null)
    8.                     shooter.Fire();
    9.             }
    10.         }
    11.  
    What this does is make it so if you uncheck or deactivate all the weapons, (I.E. before you pick up your first gun,) the script still works!

    What's interesting is the script already has some checks for null, but I got nullreference exception anyway. I guess VP never tested for this case, hence it wasn't *quite* robust enough to deal with it. Anyway. A simple tweak, and it's now more versatile than ever!
     
    Last edited: Jul 17, 2012
Thread Status:
Not open for further replies.