Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Easy Weapons - Most powerful weapon framework for Unity

Discussion in 'Assets and Asset Store' started by randomperson42, Jul 1, 2014.

  1. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    You'll probaby want to use a custom namespace. Put either the Easy Weapons projectile script or the Advanced AI projectile script into a new namespace so the names don't conflict.

    Here's a good explanation:



    Hopefully Easy Weapons will be using namespaces out-of-the box in a future update.
     
    ksam2 and hopeful like this.
  2. unicat

    unicat

    Joined:
    Apr 8, 2012
    Posts:
    425
    Thank You, i am trying this.
     
  3. gibmation

    gibmation

    Joined:
    Dec 1, 2014
    Posts:
    311
    As I could not figure out how lock movement to a single axis without screwing up some other movements, I managed to sort this by resizing and aligning both object colliders to each other this way they always have same height so it is not adjusted by the recoil script.

    XD
     
  4. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    Let me know if there's anything else I can help with.
     
  5. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,069
    It's really a cool asset. I want to use the pistol gun for an enemy but I mentioned there is no bullet prefab for it but I need bullet prefab because I need when enemy shoot at me if bullets collision with me some animations get play.
     
  6. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    Have you tried a projectile type weapon? It sounds like you need to create a new type of projectile.
     
  7. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    Last edited: May 21, 2015
  8. eagleeyez

    eagleeyez

    Joined:
    Mar 21, 2013
    Posts:
    406
    Just got it! Thank you, I have been waiting a long time for this to get on sale. To buy it was a no brainer for that price and the edition of AI Shooter support is a big bonus for me. It's looking good.

    btw. it's 65% not 60
    and I like your 25 hour sale. I thought all along that you were not from this planet
     
    Last edited: May 21, 2015
    randomperson42 likes this.
  9. christougher

    christougher

    Joined:
    Mar 6, 2015
    Posts:
    558
    Recently picked up Easy Weapons on sale and started implementing it. Forgive me if I'm wrong as I'm somewhat new to all this but when compared to other options out there it may be lacking in optimization as it does a lot of instantiating and destroying instead of relying on spawning/despawning from a pool. I'm leery to go full hog with this with performance issues in mind. Any thoughts?
     
    SpaceRay likes this.
  10. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    I agree and I am interested in this too, as I want to make a mobile game and maybe the performance would be bad (have not tested it) and maybe I wonder if for the instantiating of the destroy can be used a different way that have a spawning/despawning from a pool as suggested by christougher

    Or maybe it could be used the DestroyIt destruction manager https://www.assetstore.unity3d.com/en/#!/content/18811
    that seems to have some kind of optimisation for destruction

    Or perhaps and maybe could also be used the Core Gamekit https://www.assetstore.unity3d.com/en/#!/content/6640 that has included a pool manager and specific spawning/despawning from a pool

    Thanks for any thoughts and help for this topic
     
  11. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    Actually in version 3 a very customizable bullet hole pool system is introduced. Pooling for other GameObjects like muzzle flash FX and hit FX is on the list of things to do in the future. Unfortunately I can't give you a timetable just yet however.

    As far as mobile performance goes, I'd be interested to know what it's like if anyone has used the kit on mobile (I'm unable to test it for now.)

    As far as other weapon systems go, I'm not sure about any of them using pooling but I think you'll find Easy Weapons to be the most powerful. ;)

    Hope this helps.
     
  12. davidAns4439

    davidAns4439

    Joined:
    Apr 21, 2015
    Posts:
    4
    Easy Weapons was spectacular in 4.6.1. I've upgraded to Unity 5 and the pistol fires a single shot, then won't shoot again! And I can't switch weapons. I'm doing something wrong, obviously. I'd love a suggestion. You've done really superior work. I'm eager to get it up and running again. Please help if you've time. Thanks,
     
  13. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    Is this in a new project? Is the input working properly? This sounds like the input might not be setup properly.
     
  14. davidAns4439

    davidAns4439

    Joined:
    Apr 21, 2015
    Posts:
    4
    I just ran the demo scene after upgrading from unity 4.6 to 5. It was fabulous, running after first importing. Loved it. In 4.6 just not in 5. I will go back and review your online docs.
    Thanks,
     
  15. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    But in version 5.0, you tried running the demo in a new project?

    Is anyone else having this issue?
     
  16. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,623
    I'd assume this relates to changing from Complete Project to Scripting. When you have a plugin set as "complete project" it will overwrite existing project settings, including input settings.

    So with the older version of Easy Weapons you would simply import into a new project and run the demo. But with the plugin moved to Scripting instead of Complete Project, the project settings are not overwritten on import, and users will have to set up input before they can run the demo (unless the demo takes this into consideration).

    UPDATE: I just loaded Easy Weapons (newest version) into an existing project and it did not overwrite any input settings (which is good). However, the demo does not run, and when you attempt to run it, it spits out infinite errors along the the lines of:

    ArgumentException: Input Button Reload is not setup.
    To change the input settings use: Edit -> Project Settings -> Input
    Weapon.CheckForUserInput () (at Assets/Easy Weapons/Scripts/Weapon.cs:416)
    Weapon.Update () (at Assets/Easy Weapons/Scripts/Weapon.cs:297)

    A solution to have a working demo is to handle input within the demo and not use project settings.
     
    randomperson42 likes this.
  17. davidAns4439

    davidAns4439

    Joined:
    Apr 21, 2015
    Posts:
    4
    Yes. I ran the demo scene in a version downloaded fresh and run, for the first time, in Unity3d 5.x. But you're right,
    when I added the weapons, made other adjustments, all works well. My mistake I guess. Anyway, it's great software and I'm grateful for your work. I'm learning a lot reading your code.

    Thank yo]u
     
    randomperson42 likes this.
  18. wheelbarrow

    wheelbarrow

    Joined:
    Sep 12, 2011
    Posts:
    174
    I'm thinking about using this to fire missiles from a turret as opposed to a player- carried weapon, as I'm using RFPS for all the player stuff, so my question is, is it possible to use your scripts for this, seeing as how there will be no player input whatsoever, the turret will be firing the missiles at the player once triggered. Thanks.
     
  19. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    Yes, I would say that's possible. It's been done before - shooting projectiles from an AI (Shooter AI). Of course you would have to script whatever is triggering the weapon to fire, but it shouldn't require much if any modification to Easy Weapons itself.

    Hope this helps.
     
  20. wheelbarrow

    wheelbarrow

    Joined:
    Sep 12, 2011
    Posts:
    174
    ok, thanks for the reply.
     
  21. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    Hi. Can anyone tell me if this can be used to create a weapon that has 2 barrels (one on each side of the screen) that fire alternately?

    The view would FPS style but it would be like you were sitting in a gun nest.
     
  22. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    You can do that, but you would probably need to write a script to make it alternate between the two sides, assuming you want them both operating off the same trigger or input. Basically it would be setup as two separate weapons.
     
  23. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    Yes, exactly what I was wanting. Same trigger/input.
    What about integrating with one of the FPS assets like RFPS or UFPS, etc? Easy enough too?

    btw. The demo is fun. Don't particularly like the slide to turn movement of the characters from SAI but not sure if that be changed or not.
     
  24. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    Unfortunately I haven't tried integrating with UFPS or RFPS, as they have their own weapon systems built-in.
     
  25. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    Fair enough. I actually don't need them as it really will not be a moving character. Just need Player weapons and Enemies that wave spawn.

    If I can get away without using the other assets it might just save me some unnecessary overhead.
     
  26. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    Feel free to let me know if you need any help.
     
  27. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    Thanks I will. Just bought it now, so I will take a look at it.
     
  28. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    Just loaded into a new blank project but get this error in the demo:
    All I have done so far is set up the input as shown to include Weapon 1 - 9.
    Was there something else needed ?

    Tried to switch to a weapon that does not exist. Make sure you have all the correct weapons in your weapons array.
    UnityEngine.Debug:LogWarning(Object)
    WeaponSystem:SetActiveWeapon(Int32) (at Assets/Easy Weapons/Scripts/WeaponSystem.cs:67)
    WeaponSystem:Update() (at Assets/Easy Weapons/Scripts/WeaponSystem.cs:47)
     
  29. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    That's really strange, you just opened the demo scene?

    Check the FPS character controller in the hierarchy, and expand so you can see the child GameObjects. Under one of them will be a GameObject that's called "Weapons" or "WeaponManager". It should have the WeaponManager script attached to it. Check that component, and look at the elements in the weapons array. It should be populated with the children of the GameObject (the actual child weapon GameObjects). Hope this makes sense. This is the array that holds each of the weapons that you can switch between.
     
  30. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255

    The setup here shows:
    The Character controller as Regular_Character and yes Weapons child is in there.
    The script attached to the Weapons object is called WeaponSystem and it does show all the Weapons (size of 8, index 0 and they seem to match the objects under Regular_Character).
     
  31. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    What version of Unity are you running? I'm going to take a look at this now.
     
  32. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    Also when is this happening? Immediately when the scene starts, or when you try to switch weapons? And check the inspector for the "Weapon System" component while the game is playing, see if the array is still populated and if the index is still 0.

    The code that the warning is coming from is this:
    Code (CSharp):
    1. // Make sure this weapon exists before trying to switch to it
    2. if (index >= weapons.Length || index < 0)
    3. {
    4.     Debug.LogWarning("Tried to switch to a weapon that does not exist.  Make sure you have all the correct weapons in your weapons array.");
    5.     return;
    6. }
    This is very strange, I haven't heard of anything like this going on with Easy Weapons before.
     
  33. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    I just did a new project and fresh import and setup the inputs again, just to be sure and same result.

    5.0.2f1 Personal.

    What happens is:
    1/ I run the demo and the hand gun is shown.
    2/ I press the left mouse button and immediately it changes to the Rocket Launcher, which happens to be the last in the list. The error message is shown now.
    3/ I can the fire the rocket launcher
    4/ If I change to another weapon with the mouse wheel, the weapon is visibly changed, but as soon as I press the left mouse button to fire it changes back to the rocket launcher.

    Yes, the array is still populated and index stays showing 0
     
  34. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    That's certainly very strange - the only thing I can imagine that would be, is if you setup your input such that the left mouse button is mapped to "Weapon X" (whichever one is the rocket launcher). So maybe check your input again - and make sure the weapon input slots are mapped to keyboard numbers, or whatever your prefer.

    Edit: If that's not it, check what happens when you try to switch directly to one of the other weapons (not the rocket launcher or pistol).
     
  35. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    Yep that was it. They all fire now. Thanks.

    I do have another issue.
    The rocket launcher seems to start off tracking a target. But after a while it no longer tracks targets when fired.
    Also it seemed yesterday (but I have not test today yet), that it never tracked a target if the VB sync was turned off.

    I have also seen the rocket do an endless circle twice now.
     
  36. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    Just tested again with the VB sync off and they do track, but do lose the tracking ability like described before.
     
  37. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    That also sounds odd.

    Does it just suddenly stop tracking targets completely, for every missile fired?
    Also make sure you're not confusing the rocket launcher with the cluster bomb launcher. They both fire projectiles that look the same visually, but only the rocket launcher fires homing projectiles. The Cluster bomb launcher just fires in a straight line, and then explodes.

    Also is it after a certain amount of time, a certain amount of shots fired, or what?
     
  38. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    Yes, they stop tracking and never regain tracking. I have shot many rockets to test. 20,40 maybe.
    Yes, rocket launcher not cluster
    It happens quite early, but not consistent. I have seen it after 2, 3, 4 shots
     
  39. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    Any errors?
     
  40. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    No errors
     
  41. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    The endless circle isn't a glitch, you probably just need to increase tracking/rotating speed on the projectile.

    But as for stopping the tracking after a while, I'll try to reproduce the issue but may not get back to this until later this evening.
     
  42. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    No problem and no rush as it is early stages on this for me.

    Thanks.
     
  43. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    On looking at a little more it seems that it may only be tracking the original level enemy blocks, but not the clones/spawned ones.
     
  44. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    Yeah I'm having trouble reproducing the issue.

    Since you're not getting any errors, let's try Debug.Log statements to find where the problem is at.
    Put one like this:
    Code (CSharp):
    1. Debug.Log("UpdateEnemyList");
    In the UpdateEnemyList() function in the Projectile script (line 111).

    Then test it out, and see how frequently the debug log appears in the console. By default I believe it should be around every 1 second. Then see if it still continues printing the debug log statement after the missiles are no longer tracking. That will tell us if the UpdateEnemyList() function is still being called.

    I don't know what would cause it to not be called though, so you might also check the TargetListUpdateRate of the Projectile component in the inspector. Again it should be at about 1.0 by default, but see if it stays that way during the game. If this property was somehow set to a negative value, that could definitely cause this issue.

    Edit: To be clear, in order to check the TargetListUpdateRate property, you would have to pause the game and select a missile while it's in mid-air.
     
  45. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    OK did that and here is what I see happen.

    On the default layout and just started demo, I don't touch camera only press 8 to select the rocket launcher. Ran a few times and it seemed that it would not track after 3 missiles which had destroyed all 4 blocks.

    Yes the debug message keeps logging after it has stopped tracking targets.
    Target list update rate is at 0.5 and stays that way for working and non working rocket.
     
  46. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    Could you possibly have changed the "Seek Tag" property in the inspector of the projectile?

    Also check and make sure the the enemy prefab cubes are tagged "Enemy".
     
  47. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    I did not change anything as it was just fresh and did it twice to be sure.
    I can see the problem though I think. The spawned enemies are being tagged as Concrete.
     
  48. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    That would definitely explain it.... but it's not happening on my end, so I don't have any idea why that would happen.
     
  49. randomperson42

    randomperson42

    Joined:
    Jun 29, 2013
    Posts:
    974
    In the project view, is the actual enemy prefab (under 'Misc') tagged as Enemy or Concrete? Or does it change in-game? If the prefab itself is wrong, you could easily just change the tag. But if the prefab is tagged as "Enemy", as it should be, then something else has got to be causing this.
     
  50. Baraff

    Baraff

    Joined:
    Aug 16, 2014
    Posts:
    255
    Everything seems to be shown as untagged. Not just the Enemy.. All prefabs.