Search Unity

Deftly - Flexible Top Down Shooter System

Discussion in 'Assets and Asset Store' started by LaneFox, May 27, 2015.

  1. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    This is a really nice asset and reminds me so much of gauntlet.

    Do you have an ETA on the Rewired integration? Using the Unity input system is very painful when you are used to Rewired.
     
    LaneFox likes this.
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Hi @longroadhwy - As much as I love Rewired, Deftly's InControl support works great, although it's admittedly an extra purchase if you have Rewired but not InControl. Like Rewired, InControl has XInput force feedback and everything you need in a good Gauntlet-style shooter.
     
    LaneFox likes this.
  3. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,521
    Glad you're liking it! I'm a big fan of Gauntlet. =)

    I don't have any ETA yet. I am aware people would like rewired support and I'm interested in supporting it but for a while I'm trying to only address bugs and simple adjustments as I have other pressing things that need my time.

    In the meantime as Tony points out, the InControl support is good to go (albeit extra, in your case).
     
  4. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    @TonyLi @LaneFox

    I might be the one of the very few people who prefer Joysticks over gamepads on 99% of the games I play. Definitely prefer the arcade like experience with real joysticks.

    I will look into doing my own Rewired integration while I wait for the official Rewired integration from Deftly.
     
  5. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,521
    Great, let me know how you get along.
     
  6. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    While I'm on the forums answering support requests of my own, I thought I'd submit a feature request for Deftly.

    Would you please consider adding aim assist? A couple friends that playtested my last prototype (several months ago; haven't had time since then) aren't great at twin stick shooters. I slowed the pace of combat so the game is more about exploration than bullet hell, but their aim is still atrocious. An alternative might be an option to automatically aim in the direction the player is walking.

    Another little issue: I downloaded version 1.0 and imported the InControl and Co-Op package into a new, empty Unity 5.3.4 project in Windows 10. Both co-op scenes (0 Menu and 1 First Level) have a missing prefab. For example, 0 Menu has: _Persistent, Environment, and a Missing Prefab.
     
    LaneFox likes this.
  7. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,521
    Sure, I'll look into adding Aim Assist for controllers. Aiming in the direction you're walking should be pretty easy to add and I've wanted to add it for a while too anyway.

    Odd, I'll check it out and make sure its fixed in the next update.

    Thanks for the feedback!
     
    TonyLi likes this.
  8. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    I did a first pass with Rewired already and got most things working already. I am using Unity 5.4.3 and Rewired 1.0.0.106 on Windows.

    @TonyLi

    The Aim assist is an interesting idea. I wonder if using a standard 8 way joystick would make it easier than the analog sticks that are on gamepads when it comes to aiming?
     
  9. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Probably. Good point. It might be frustrating though for the players who are good at twin sticks and want fine-grain aiming. If Lane can implement aim assist, that'll be the best solution for my other less-than-great players. :)
     
  10. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    It would be interesting to see if your players would have better performance with two real joysticks like ThrustMaster T16000M than just the two sticks on a gamepad.
     
  11. JincSoft

    JincSoft

    Joined:
    Aug 30, 2014
    Posts:
    14
    I've had the pleasure of using Deftly (a version prior to 0.7.5 fyi) for a mobile project and it was pretty easy to work with. I did end up modifying the code so I could use ReWired and optimize some areas but for the most part it was very easy to setup and tweak to how we wanted (even implementing shotguns was no problem). The only thing that I would say is not mobile friendly are the foreach loops and lack of caching that are mostly found around the AI code. This shouldn't be a problem for most people though if they're targeting Web or Desktop and I haven't had a chance to look through the most recent version of Deftly to see if it has been changed. When we get our current game out the door I will be looking forward to playing around with the co-op update.
     
    LaneFox likes this.
  12. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    More follow up to my last post.

    This was a fast Rewired integration just to get something up and running quickly. It was straight forward. I did everything in place on top of Deftly v1.0 using Rewired 1.0.0.106 and Unity 5.4.3f1 (Windows).

    I made changes in Assets\Deftly\Core\PlayerController.cs file only.

    At the top of the file (at line 4 in the original file PlayerController.cs I added). My line number references will be to the original file.

    Code (CSharp):
    1. using Rewired;
    On line 12 in the original file I am not sure why Rewired is spelled ReWired rather than Rewired. Should be changed to Rewired.
    Code (CSharp):
    1. public enum ControlVersion { Stock, InControl, ReWired }
    On line 13 commented out this line and replaced with a Rewired version.
    Code (CSharp):
    1. public readonly ControlVersion Version = ControlVersion.InControl;
    changed to
    Code (CSharp):
    1. public readonly ControlVersion Version = ControlVersion.ReWired;
    On line 17 I added the following code:
    Code (CSharp):
    1.  
    2.         public int RewiredPlayerId = 0;
    3.         private Player Rewiredplayer;
    4.  
    5.         public bool UseRewired = true;
    6.         // -- end rewired specific additions
    On line 55 changed
    Code (CSharp):
    1. public bool UseInControl;
    to
    Code (CSharp):
    1. public bool UseInControl = false;
    Within the Awake function on line 79 added the following
    Code (CSharp):
    1. Rewiredplayer = ReInput.players.GetPlayer(RewiredPlayerId);
    Within the Aim function on line 128 changed
    Code (CSharp):
    1. if (UseInControl)
    to
    Code (CSharp):
    1. if (UseRewired)
    Within the GetMovementAxis function on line 230-235 changed Input.GetAxis version to Rewired versions.
    Code (CSharp):
    1. return new Vector3(
    2.                         Rewiredplayer.GetAxis("Horizontal"),
    3.                         0,
    4.                         Rewiredplayer.GetAxis("Vertical"));
    Within the GetAimAxis function on line 244 replaced the input.mousePosition with
    Code (CSharp):
    1. return new Vector3(Rewiredplayer.GetAxis("Mouse X"), 0, Rewiredplayer.GetAxis("Mouse Y"));
    On lines 248 to 253 and also line 255 changed for input handling from Input.GetAxis or Input.GetButton to Rewired versions. This is not the full code change below but just a short snipit.
    Code (CSharp):
    1. Rewiredplayer.GetAxis("Fire1");
    2. Rewiredplayer.GetAxis("Fire2");
    3. Rewiredplayer.GetButton("Interact");
    4. Rewiredplayer.GetButton("DropWeapon");
    5. Rewiredplayer.GetButton("Reload");
    6. Rewiredplayer.GetAxis("Sprint");
    7.  
    On line 254 within InputChangeWeapon function I expanded this to handle the cases of mouse wheel, button and dpad a bit differently. Some of these ideas are based loosely on the Rewired integration with opsive's Third Person Controller.

    Code (CSharp):
    1.  if (Rewiredplayer.GetButton("ChangeWeapon")) return 1f;
    2.             if (Rewiredplayer.GetButton("Next Item")) return 1f;
    3.             if (Rewiredplayer.GetButton("Previous Item")) return -1f;
    4.  
    5.             return 0f;
    Rewired handles keyboard/mouse/controller equally well so I did not have to make special cases for controller vs keyboard vs mouse as I saw in some of the InControl addon code included in the file InController.cs.

    Testing was limited to only keyboard/mouse/xbox360 controller. I did not test with any of the flight controllers yet. But I plan on adding Rewired's controlmapper to make in-game remapping of controllers much easier.

    A prefab of the Rewired input manager is attached to make it easier to integrate.

    CRITICAL NOTE: Download the attached Rewired input manager prefab (in a zip file). Unzip it and then add it to your scene for the above changes to work. You must own Rewired asset for it to work.
     

    Attached Files:

    Last edited: Dec 8, 2016
    ShadowFenix and LaneFox like this.
  13. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,521
    Great to hear about your success with Deftly! Do you have a link to the project? The co-op uses InControl, but you can pretty easily migrate it to ReWired after seeing how the example scripts work. 1.0 doesn't have any significant optimization changes, its mostly QoL stuff and minor bug fixes, but 0.7.5 was more substantial.

    The AI is definitely lacking in the optimization department, I had a lot planned to get it more mobile friendly but figured most people would roll their own anyway so I shifted to other features.

    Thanks for the robust follow up! Seems reassuringly easy to make a Rewired controller. I know rewired has the more advanced control map stuff and thats what I wasn't familiar with, but it seems like it is easy to tap in to. =)
     
  14. JincSoft

    JincSoft

    Joined:
    Aug 30, 2014
    Posts:
    14
    Just got approved by Google
    https://play.google.com/store/apps/details?id=com.ByChanceGameStudios.TheLastHope

    For the ReWired controls I took the InControl script and modified it for a more mobile friendly twin stick layout (left stick rotates and moves character if the right stick is not receiving input). I saw the release notes for 0.7.5 when it came out but our project was too far in development to update to that version. I had already fixed the bugs listed and optimized for mobile so we were on a code freeze for a lot of the plugins.
     
  15. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    That is great news that your game is available. That is an interesting method how you handle the input if right stick is not being used too.
     
  16. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Once you have the Rewired Input manager setup it is really easy to work with. It makes it easy to share since you can just include it as a prefab with your addons too. Customers still have the full Rewired product to use the prefab but it can get game developers up and running easily. Just drop into a scene and away they go.
     
  17. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    The same problem using Unity 5.4.3. Is there a workaround for this missing prefab issue?

    @LaneFox

    Do you have an ETA for an official fix?
     
  18. JincSoft

    JincSoft

    Joined:
    Aug 30, 2014
    Posts:
    14
    The editor setup side is definitely more confusing than the coding side for a one or two player setup followed by getting used to an event based system. Hardest part would probably be deciding how many features you want implement for QoL purposes (guavaman.com/projects/rewired/docs/HowTos.html for anyone that wants to read up on a few How-Tos).
     
  19. hanger102

    hanger102

    Joined:
    Jan 3, 2013
    Posts:
    13
    Is there a way to use mouse and keyboard for the coop demo?
     
  20. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Would you be expecting to only be using Unity Input for Co-op mode? Are you were using any third party products (InControl or Rewired) for input handling? I would expect you would have one player using keyboard/mouse and the rest on controllers correct? That is the type use case I am looking myself but I will be using Rewired.

    Based on the included Deftly 1.0 Documentation (PDF included with the asset) on page 14 says "The built in Co-op example requires InControl, so follow the steps for getting InControl imported and setup first" the answer would be no without making your own changes.

    You would have to look into this Assets\Deftly\Core\PlayerController.cs at the very minimum to make changes. Since most of the code for the Co-op addon seems to have if (UseInControl) conditionals in most places. So it is expecting controllers and not keyboard and mouse for the Co-op. There is no method to indicate which player will be using keyboard/mouse in the code so that is another issue.

    See also some additional comments on PlayerController.cs from the developer on his website can be found here:

    http://www.cleverous.com/blank-mqiue

    NOTE: It would be easier using Rewired in my opinion to handle the case for keyboard/mouse for one player and other players on controllers. But regardless it would require making changes to the Co-op code and maybe to do it correctly. In the Rewired asset there is a 8 player simple example (Assets\Rewired\Examples\EightPlayers) that is basically a good example (use case) for allowing two players to use different parts of the keyboard or controllers and the rest of the players using controllers.

    @TonyLi

    I think I saw mentioned early in the thread that you have tested the Co-op using 4 players using gamepads (using InControl)?
     
  21. BilginSahin

    BilginSahin

    Joined:
    Jul 2, 2012
    Posts:
    48
    Hey i bought your Asset and i like it so far! i have a few question.
    1) The Hand of the Character is rotated wired. How can i fix this? Tryed everything in the inspector to rotate but nothing worked.
    2) Is it possible to setup the camera in ISO view?
     
  22. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,521
    1. Do you have a pic?
    2. You should be able to use Orthographic cameras fine.
     
  23. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,521
    Short answer: Not without changing the included demo scripts.

    Long answer: The hitch is the menu system (PersistentHandler.cs) really, the demo scene and player management scripts are specifically for using InControl 'Devices' to capture and identify Players when they press the trigger, then spawn a thing on the menu for them to pick a character with. That menu picker looks for Device inputs. If you wanted to use a keyboard for this you would have to adjust the code to look for keyboard input instead of controller buttons or make a more conditional check of the character's control setup - the demo assumes everyone is playing with a controller (InControl Device).

    I was hoping to make a better example that covered doing that more comprehensively but figured there were way too many options for menus and how devs might handle the whole high level Player / Controller situation so I left it where it is now. Deftly has a lot of QoL features and easy helpers but at some point every game's development is absolutely going to branch off and require custom code for stuff like that.
     
  24. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,521
    It's the Main Camera, not really sure why it isn't finding it. Will replace it without a prefab link.
     
  25. BilginSahin

    BilginSahin

    Joined:
    Jul 2, 2012
    Posts:
    48
  26. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,521
    You've got to setup the model hand orientation settings. Depending on how the model is rigged and the bones are oriented every model will be different and I don't know of any way to automagically do that for you.

     
  27. BilginSahin

    BilginSahin

    Joined:
    Jul 2, 2012
    Posts:
    48
    Hey thanks for reply. Can you maybe help me to find the right settings if i send you the model? i tryed it but didnt figured it out
     
  28. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    At the time, Deftly didn't have a co-op mode. But since the code is so nicely designed it was easy to implement it myself. I described it in this post. I actually haven't looked at Deftly's new built-in co-op features yet.

     
  29. vertigostudios

    vertigostudios

    Joined:
    Oct 1, 2012
    Posts:
    101
    Hi Guys, Im wanting to recreate an old game and bascially have all of the main character models done.

    PreSale question.

    Ive modelled and textured a character and used mixamo for rigging the character. Here is the real question. How difficult is it for me to add my own character to Deftly, Is it a case of dropping the rigged character prefab onto the controller and all of the current Deftly animations work as normal or am I missing something.

    Would is also cause problems with my character being a toon character IE, short arms and legs.

     
  30. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,521
    You can use any model. Size and limb scale doesn't matter.

    Import as humanoid is ideal, mecanim sets up the avatar and deftly hooks into the animator to do IK stuff. Using humanoids + IK basically equips weapons and brings the hands to the IK points specified by the weapon being equipped.

    Each models bones could be differently rotated so you have to tell deftly which way is up, but after that it's always accurate. Mecanim iirc is always the same so the same settings should work for every model. The video a couple posts up explains how it works.

    If you don't want to use IK features there is an optional weapon mount gameobject field, any weapons will be parented to it and not use IK stuff. This allows you to basically do whatever you want, eg make spiders carry axes and use more traditional animation setups.
     
  31. vertigostudios

    vertigostudios

    Joined:
    Oct 1, 2012
    Posts:
    101
    Hi again, thanks for the speedy reply.

    I'll take the plunge and see how it goes.
     
  32. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,521
    Great, feel free to post if you're having trouble getting along.
     
  33. BilginSahin

    BilginSahin

    Joined:
    Jul 2, 2012
    Posts:
    48
    hey the moronbot only attacks once then he stops. seems to be a bug
     
  34. BilginSahin

    BilginSahin

    Joined:
    Jul 2, 2012
    Posts:
    48
    another question: there are xp and level stats etc at the subject script. how to use them? where will we be xp gained?
     
  35. vertigostudios

    vertigostudios

    Joined:
    Oct 1, 2012
    Posts:
    101
    Hi Lane, I know your probably busy and you said if I had any questions to ask away.

    I'm using the following tutorial on getting my little character moving around (
    )
    and I think I done everything that was asked of me in the tutorial, however - my little guy runs around still in the 'T' pose as hes just asking for trouble running around with his arms out spread.
     
  36. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,521
    Is the character rigged properly and preview animations work fine on it?

    Mecanim should take care of animating the character, so as long as you put the Animator at the top of the hierarchy and the Animator works fine then it should animate the character.
     
  37. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,521
    You'll need to be more specific, this seems to work fine.

    The "Primary Stats" tab is where you handle stat growth. If you want to do anything with them you'll have to modify the scripts to consider them during damage events and stuff. The stats are just there as a barebone start for you to take it further if you wanted to use a stat system.
     
  38. vertigostudios

    vertigostudios

    Joined:
    Oct 1, 2012
    Posts:
    101
    Hi again, the character was rigged with Mixamo. Ill have another play and see what I can come up with.
     
  39. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Make sure your character's hierarchy looks like this:
    • Main GameObject: Capsule Collider, Rigidbody, Subject, Player Controller
      • Empty GameObject: Animator (Deftly Standard animator controller)
        • Mesh GameObjects (e.g., Body, Eyes, etc.)
        • mixamorig:Hips (top of skeleton GameObject hierarchy)

    These are the Subject settings I use for Mixamo characters:

     
  40. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    A Rewired specific version to "press controller to join" has a nice write up on the same type of issue at this location.

    http://guavaman.com/projects/rewired/docs/HowTos.html#press-start-to-join

    X-arcade's Tankstick was the first use case I wanted to use Rewired for originally. So with the Gauntlet like features of Deftly it makes a perfect fit in my opinion. Just have to use fire in the same direction you are moving. Also it has more than enough buttons that you can handle both fire button and switching weapons and other interactions with Deftly.

    With regards to using different part of the keyboard for two players I can think of a perfect example use case if one is using X-arcade's tankstick. Which has two joysticks and buttons but it just emulates a keyboard so it is multi-platform. In my case I was thinking of using two of the tanksticks for a total of 4 players (you can change the hardware mapping for keyboard mapping for the second tankstick so it does not conflict with the first tankstick).

    Since it does have player start buttons (like an arcade machine) on tankstick you can use that for "push" to join also.

    https://shop.xgaming.com/collection...cts/x-arcade-tankstick-trackball-usb-included

    tankstick_joystick.jpg

    With Rewired it makes it easier since I just do different keyboard mapping for each player for the same actions. Since the actions are in the code I do not have to handle each specific case of keyboard handling in the code for all 4 players since I only have to worry about the actions.

    First you create two layouts for the two players (or how many layouts you need if you have 4 players)

    rewired_keyboard_layouts.JPG

    The first player mapping is here.

    rewired_player1.JPG

    And example using the second player mapping here.

    rewired_player2.JPG

    Critical Note: Example Rewired input manager prefab that includes X-arcade tankstick mapping. (unzip and add to your scene)

    I made changes in Assets\Deftly\Core\PlayerController.cs file within the Aim function to support firing in the direction you are moving to support X-arcade tankstick also (since X-arcade is only using 1 joystick and not two joysticks). X-arcade Tankstick has the same compatible mappings as X-arcade dual stick and X-arcade solo so it should support those without any changes using the default mode1 mapping.

    Code (CSharp):
    1. // _aimInput = GetAimAxis;
    2.   _aimInput = GetMovementAxis;
    This is in addition to the Rewired related code changes made in this original message (#312) in this Deftly forum thread
    https://forum.unity3d.com/threads/r...own-shooter-system.328453/page-7#post-2865363
     

    Attached Files:

    Last edited: Dec 13, 2016
    TonyLi likes this.
  41. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Thanks for the write up. It is always nice to see the original motivation for how co-op was created.
     
  42. vertigostudios

    vertigostudios

    Joined:
    Oct 1, 2012
    Posts:
    101
    Thanks, its appreciated.
     
  43. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    I was looking into this recently and I just made this change in the Aim function to support firing in the direction you are moving.

    I made changes in Assets\Deftly\Core\PlayerController.cs file

    Code (CSharp):
    1. // _aimInput = GetAimAxis;
    2.   _aimInput = GetMovementAxis;
    It works fine for my purposes. I was thinking of adding a Rewired action to allow the player to turn on and off aim assist. I tested it with Xbox 360 controller, keyboard and flight controller and it seems to be a reasonable solution.
     
    TonyLi likes this.
  44. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Thanks for the info.
     
  45. BilginSahin

    BilginSahin

    Joined:
    Jul 2, 2012
    Posts:
    48
    Hi after testing the enemys i have noticed that a enemy doesnt go back intro wandering/patrol if he for example loose the sight to the target. can you please implement it? xD
     
  46. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    Based on what I have seen from the Deftly v1.0 documentation on page 2 it says "AI can be designed with the Intellect script" That script is found in the Assets\Deftly\Core\Intellect.cs is where you would need to make changes if any.

    On the website Intellect.cs page it does mention PursueRange but it did not find a direct reference in the source code. Probably a combination of mood, range (based on the current code) will get something along those lines.

    The website url is what I am using for reference.

    http://www.cleverous.com/blank-cqaz5
     
  47. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,521
    This is kind of a stealth mechanic that I never fleshed out. Basically the current assumption is that if an enemy engages you then it will pursue you until it dies. If the enemy were to ever disengage then there are several additional features that would need to be added to support it properly (without being exploitable, and feel natural) but they ended up being more complex than I was ready to commit to adding just for the sake of disengaging a target. After all, its a shooter kit; stealth isn't exactly expected.

    The online API ref docs were added to see if there was an interest in having them. Right now they're manually maintained, but if there is enough interest then I would move to doxygen or something to automate creating them and have an API reference file in addition to the regular getting started document.
     
  48. BilginSahin

    BilginSahin

    Joined:
    Jul 2, 2012
    Posts:
    48
    i think you just can simple check if the player/currentTarget is in line of sight and if not (and he is in chase/attack state) then go back to wandering/patroling. this is the simplest solution and adequate. also you could save the last seen position of the target so the ai runs there and starts look around or something. in the intellect.cs you have the method ProcessConditions(). this is where you check the conditions for the different states? is there any raycast in combat state which is casted? then you could use that one
     
  49. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,521
    If you feel there is a simple solution, give it a try. Intellect is virtual so you can derive your own classes.
     
  50. longroadhwy

    longroadhwy

    Joined:
    May 4, 2014
    Posts:
    1,551
    That would be great to have an on-line API reference in addition to the current PDF documentation.