Search Unity

[RELEASED] TPSA - Third Person Shooter System (template)

Discussion in 'Assets and Asset Store' started by Stiffx, Jan 24, 2015.

?

What additional pack would you like to see in TPSA?

Poll closed Apr 1, 2015.
  1. Enemy AI Shooter

    44.4%
  2. Friend AI (like sherry from Resident evil 4)

    55.6%
  1. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Next, use the second set of Mouse X and Mouse Y (you may need to add them) and set them to joystick axis and for me I had to use 4th and 5th axis. That should enable the rotation with the second joystick. I think that's about as far as you can go without getting into code.
     
    Stiffx likes this.
  2. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
    Yeh it did work and the rest is digging into code.

    No short cuts if I am to use unity I need put more time in on my coding

    Thanks drewradley
     
  3. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    The code is actually pretty simple. Here's an example:
    look for
    if (Input.GetKey(KeyCode.LeftShift))

    around line 410 of the player control script and change it to


    if (Input.GetKey(KeyCode.LeftShift)|| Input.GetButton ("Sprint"))


    Then set up a Sprint button in the input manager which uses joystick button X where X is the number of the joystick button you want to use.You'll need to look for key and mouse buttons to change. anything that uses GetKey, GetKeyDown, GetKeyUp, change to GetButton, GetButtonDown, GetButtonUp. Same for the various MouseButton places and set up all the inputs to use various Joystick buttons and Axis. This was my first attempt to add controller support myself and it took less than an hour. If in doubt, turn to Google. I found some pretty good help just by searching for "Unity XBox Controller".
     
    Last edited: Apr 28, 2015
    Stiffx likes this.
  4. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
    Here are my findings
    mapping TPSA to xbox 360 controller while preserving standard keyboard & mouse controlls
     
    Last edited: Apr 28, 2015
  5. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Video set to private.
     
  6. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
    dont know why it wen \t 480p when premiere export 1080p

    but you can see it
     
  7. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Hard to read the code though. I think YouTube processes HD slower and will eventually add that.

    In any case, for the camera moving when running, make sure you didn't use one of the same axis for move and look. Also check the "gravity" of the axis as that could cause it to move on it's own. It's it's not zero, set it to zero.

    Since I've edited my code a lot, it's possible that line doesn't exist in the original or is nowhere near line 410. In any case, if you search through the code for all instances of "GetKey" you should find it no matter. It's in the ApplySpeed fiunction, right below "if(IsAimed).
     
  8. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
    GetKeys like theses and more

    if (Input.GetKeyDown(KeyCode.Alpha1))
    PWController.SelectPrevWeapon();

    if (Input.GetKeyDown(KeyCode.Alpha2))
    PWController.SelectNextWeapon();

    if (CanPickup && (Input.GetKeyDown(KeyCode.E)))
    {
    if (canInteract())
    PickObject();
    }

    if (Input.GetKeyDown(KeyCode.E))
    {
    if (canInteract())
    StepOver();
    }

    //Cover
    if (Input.GetKeyDown(KeyCode.X))
    {
    if (canInteract())
    Cover();
    }

    Hope I can post this if not please tell me and I will delete?



    SO change to GetButton, GetButtonDown, GetButtonUp and add button number thats on unity wiki

    then add them in input manager?
     
    Last edited: Apr 28, 2015
  9. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Now you need them change it to something like:
    Code (CSharp):
    1. if (Input.GetKeyDown(KeyCode.Alpha1) || Input.GetButtonDown("Previous"))
    2.  
    3. if (Input.GetKeyDown(KeyCode.Alpha2) || Input.GetButtonDown("Next"))
    4.  
    5. if (Input.GetKeyDown(KeyCode.E) || Input.GetButtonDown("StepOver"))
    6.  
    7. if (Input.GetKeyDown(KeyCode.X) || Input.GetButtonDown("Cover"))
     
  10. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
    ok this is code untouched

    if (Input.GetKeyDown(KeyCode.Alpha1))
    PWController.SelectPrevWeapon();

    if (Input.GetKeyDown(KeyCode.Alpha2))
    PWController.SelectNextWeapon();

    if (CanPickup && (Input.GetKeyDown(KeyCode.E)))
    {
    if (canInteract())
    PickObject();
    }

    if (Input.GetKeyDown(KeyCode.E))
    {
    if (canInteract())
    StepOver();
    }

    //Cover
    if (Input.GetKeyDown(KeyCode.X))
    {
    if (canInteract())
    Cover();
    }

    this is new version


    if (Input.GetKeyDown(KeyCode.Alpha1) || Input.GetButtonDown("Previous"))

    if (Input.GetKeyDown(KeyCode.Alpha2) || Input.GetButtonDown("Next"))

    if (Input.GetKeyDown(KeyCode.E) || Input.GetButtonDown("StepOver"))

    if (Input.GetKeyDown(KeyCode.X) || Input.GetButtonDown("Cover"))
     
    Last edited: Apr 28, 2015
  11. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    Don't forget to do the same for the mouse buttons. These usually deal with aiming and firing. Just search through the script for every instance of "GetMouseButton". For me, they start about line 560 (in "#region common").
     
  12. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165

    ok thanks man. Hope I dont get errors but if so thanks to you I know how to do it all over again.


    I am Much appreciative.
     
    Last edited: Apr 28, 2015
  13. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    If you run into any errors, let me know and I'll help you fix them. Shouldn't need to start over just for a little error! The only places you may run into issues are when there are input lines which use an && to string together another conditional such as line 568 (for me) where it checks to see if you are using a scope as well as a mouse button. In that case, you'll need to add a second set of parenthesis to keep the two inputs together like this (not actual code):

    if(mousebuttondown(2) && useScope)

    becomes

    if ( (mousebuttondown(2) || getbuttondown("Aim") ) && usescope)
     
    Stiffx likes this.
  14. Stiffx

    Stiffx

    Joined:
    Oct 27, 2014
    Posts:
    455
    Thank you @drewradley for helping him while I'm updating the pack, you are a true hero :).
    I would like talk to you guys about this input subject. How do you guys think we could solve this issue and bring some easy config out of the box to anyone?

    Please share your ideas and let's find the best solution.

    Thank you all
     
  15. Stiffx

    Stiffx

    Joined:
    Oct 27, 2014
    Posts:
    455
    @relacon are you using the version 1.3 from my website or the assetstore version? If you are using the assetstore version please update it there's a lot of fix at the new version.
     
  16. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
    I was using asset store 1.2 I got the update downloaded but when I unzip i get a bunch of errors from the zip file.

    i will request new file and try again.

    Thank you drewradley

    and Thank you stiffix

    I love this asset alot so Im will to pull my hair out to learn C# to become a better dev
     
  17. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
    nvm

    downloaded zip file I get errors when trying to unzip.

    Hey hey here goes the best news.

    The update server is online and working. But before you download I have some considerations:

    1 - Please do not share your invoice number otherwise not authorized people can use your unity purchase information.
    2 - Do not kill the server :D please download the file one time only, but if you do need it again wait at least one hour.
    3 - The file is compressed with 7-zip, if you don't have it, download it here: http://www.7-zip.org/
    4 - The version you are about to download is not a final release, it will have allot of bugs so you don't need to freak out.
    5 - If you guys use it the right way I promise to keep it alive until next year.
     
    Last edited: Apr 29, 2015
    Stiffx likes this.
  18. Stiffx

    Stiffx

    Joined:
    Oct 27, 2014
    Posts:
    455
    haha that's it, I was going to ask you about 7-zip, it's good that you find out.
     
  19. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
    unzipped file so just a simple drag n drop to project file :)
     
    Last edited: Apr 29, 2015
  20. Stiffx

    Stiffx

    Joined:
    Oct 27, 2014
    Posts:
    455
    Yes, but I prefer if you create a separate folder to drag files on. Cause you can lose whatever you changed at old files
     
  21. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
    ok I did that thank you.

    1.Question is there a need for a xbox 360 controller script or add on to your asset or am I the only one?

    2.error IndexOutOfRangeException: Array index is out of range,

    line 82? is that an input manager thing?
     
    Last edited: Apr 29, 2015
  22. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    I think that all you need to do is change all the inputs to use buttons rather than keys and mouse buttons. Then anyone can set it up in the input manager without needed to change the code.
     
    Stiffx likes this.
  23. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
    wow Im on it :)

    So just do a normal mapping with input manager change type to joystick and map every thing

    WOW thats pimpish. thanks bro you rock
     
    Stiffx likes this.
  24. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165

    Out of the box when play is hit The keyboard and mouse should work and a standard xbox 360 wireless/wired should work

    with out having to change anything in code or input manager. Or put together a video how you set up a 360 controller to

    work with all the functions with TPSA (man there's wealth of functions to make a great game)

    Also you could create a input manager asset that enables the user to map to a standard type xbox 360 type controller.

    TPSA is amazing it really is, I guess most are PC gamers who use keyboard and mouse and yes it is way faster to aim.

    But it be nice to have the option to choose Pc vs Console config.
     
    Stiffx likes this.
  25. Stiffx

    Stiffx

    Joined:
    Oct 27, 2014
    Posts:
    455
    I believe the @drewradley solution is the simple and fast, because setup buttons at input manager is very easy and very intuitive. Thanks for sharing :)
     
  26. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    I watch a lot of reviews and "let's play" and one of the most common complaints is the lack of configurable controls (should they be lacking) so I always try to replace any hard coded controls with a configurable button. I just wish Unity's own runtime configuration wasn't so ugly! Haven't checked it out in 5 yet so perhaps that has improved as well.
     
  27. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
    yeh you right it is the easy way but only bad thing is no (A = joystick button 0) Since input manager wont go to joystick

    button 0 on joy num

    thanks for your input :)
     
  28. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
    question your not using 5 now? I'm guessing you bought pro 4 and I would do the same. but in 5 it seems the input

    manager is the same but you now can make AAA graphic, more power as an engine.

    I love unity it reminds me of Maya. lol But isn't unity more or less a big compiler and an engine so maybe they

    figure the devs need it just code it.
     
  29. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    I considered sticking with 4 pro but after playing around with 5 (since this now requires it along with a few other assets I use) I decided to use 5. It is a lot better than 4 pro!
     
    ISH_the_Creator likes this.
  30. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165

    OK lol my bad but I still cant map to xbox 360 using input manager I get the move and move camera but thats it.

    I went here http://wiki.unity3d.com/index.php/File:X360Controller2.png for help but I get still get errors and none of the triggers, buttons work.
     
  31. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    What errors are you getting?
     
  32. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
    I'm uploading a video now

    Man I thought rigging and animation was easy but game DEV is hard lol

    both analog sticks work but thats it
     
    Last edited: Apr 29, 2015
  33. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    The easy fixes are every error that says a specific button has not been set up. Just add the button it is looking for in the Input Manager. For instance when it says the "Submit" button has not been set up, just add a new one and name it "Submit" (it is case sensitive so be aware of that). That may fix some of the other errors you are getting as well.
     
  34. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
    thanks

    I have 2 other controllers that out the box supports 360 controllers but its only a controller not a template like this.

    If I have to dig through code I rather do it here.

    I just have to map all the buttons and triggers. I got both analog sticks working fine.

    I just got figure it out. I got notes from before so I should get it.
     
  35. drewradley

    drewradley

    Joined:
    Sep 22, 2010
    Posts:
    3,063
    One other thing I would like to see is to make it so the player can spawn and automatically assign certain things like the camera. I tried to do that myself, but never had much luck. Always ended up a mess of things.
     
  36. jbooker410

    jbooker410

    Joined:
    Mar 9, 2014
    Posts:
    41
    I am trying to write my own AI to use with TPSA. Im having trouble understanding the send message from the raycast for guns and melee. Trying to write code for my AI to receive the message but cant get it to work. If anyone out there can help me with some code even if its as simple as printing Got Hit to the console I can take it from there. Thanks Much.
     
  37. Stiffx

    Stiffx

    Joined:
    Oct 27, 2014
    Posts:
    455
    Hi there, which version of TPSA are you using in first place?
     
  38. jbooker410

    jbooker410

    Joined:
    Mar 9, 2014
    Posts:
    41
    I am useing the 1.3 in unity 5
     
  39. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    It is lacking Gears Of War or Uncharted ability to fire from the cover staying in cover mode.
    For a TPS using a cover system this is an essential requirement.
     
    snackzilla likes this.
  40. Rose-Remnant

    Rose-Remnant

    Joined:
    Nov 14, 2012
    Posts:
    123
    When I started messing with the game the AI seems to fall through the terrain if you change it or add a new. Anyone Know how to fix this?
     
  41. ISH_the_Creator

    ISH_the_Creator

    Joined:
    May 8, 2013
    Posts:
    165
    can rain AI integrate with TPSA with out having to code?
     
  42. Stiffx

    Stiffx

    Joined:
    Oct 27, 2014
    Posts:
    455
    Did you re-bake the navmesh? the only reason to that is if you use an old version of the project with unity 5 without re-baking the navmesh
     
  43. Stiffx

    Stiffx

    Joined:
    Oct 27, 2014
    Posts:
    455
    I don't really know, I've never used this software before. You could try it and tell us your results :)
     
  44. Stiffx

    Stiffx

    Joined:
    Oct 27, 2014
    Posts:
    455
    Th send message is quite simple: I need to understand what are you trying to do first. Show me what are you doing
     
  45. Stiffx

    Stiffx

    Joined:
    Oct 27, 2014
    Posts:
    455
    Hi there for everyone who tried to setup new character please add a small fix to the TPSA_CharacterSetup.cs file located at Scripts/Editor at line 104

    change:
    Code (csharp):
    1. if (CameraLookAt.parent != Camera.transform)
    to this
    Code (csharp):
    1. if (CameraLookAt.parent == Camera.transform)
    My bad :oops:
     
  46. Archania

    Archania

    Joined:
    Aug 27, 2010
    Posts:
    1,662
    Hi Stiffix... Just seeing how everything is going...
    What is the game plan?
     
    Stiffx likes this.
  47. Stiffx

    Stiffx

    Joined:
    Oct 27, 2014
    Posts:
    455
    Hi there @Archania thanks for asking. Right now I'm working on the the animation re targeting, let me explain why: Unity Mecanim says you need to use a two spine character skeleton, and my last character (current) has 3 (3ds max standard biped skeleton). I've finished the new player controll and I'm still fixing some animations for two spines. And I still want to add a buttons configuration to solve xbox controller or keyboard use.

    Normally I work very fast, but these days I'm also working at night at normal job to get some extra income, it will end next week.
    And last but not least there's a new free level (Rio de Janeiro from Brazil) I'll include at TPSA (it's 50% complete).

    Again thank you all for your support and patience.

    :)
     
    Last edited: May 6, 2015
  48. Archania

    Archania

    Joined:
    Aug 27, 2010
    Posts:
    1,662
    Very cool. I was going to start and implement my character with your system but from the sound of it, I should wait?
    Looking forward to the update!
     
  49. Stiffx

    Stiffx

    Joined:
    Oct 27, 2014
    Posts:
    455
    Please yes, I recommend you to wait a little bit more, the new system is easier to understand, has new visual tools via inspector to help you and some bug fix.

     
  50. Archania

    Archania

    Joined:
    Aug 27, 2010
    Posts:
    1,662
    You got it.
    thanks for the fantastic work on this. Just keeps getting better and better!
     
    Stiffx likes this.