Search Unity

Third person shooter - Learning project

Discussion in 'Made With Unity' started by TwiiK, Mar 29, 2009.

  1. LordsWarrior

    LordsWarrior

    Joined:
    Jun 3, 2009
    Posts:
    58
    Nice one man..

    Its kinda disturbing and satisfying shooting those block heads!


    -P
     
  2. Dexter

    Dexter

    Joined:
    Apr 15, 2009
    Posts:
    104
    Very good weapons, and good choice for the sniper rifle AS 50 ;)
     
  3. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    A third work in progress weapon.

    The Walther p88 Compact:




    Wires:



    I also tried out some normal mapping and here are my results:



    Looks pretty good if I may say so. Much better than I had hoped seeing as I'm new to normal mapping. :)

    The Walther only lacks a few details and I have to remove the symmetry, then the high poly is done.

    I think it's fairly safe to say it's quite accurate because I used my own CO2 replica as reference and that is supposedly nearly 100% correct.

    I haven't done any more to the first two models, those will have to wait. :)
     
  4. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    I made a quick first person controller example project for Thomas Pasieka over at theunityartist and I thought I'd post it here as well because I get a lot of questions by PM about these things.

    It's quite crude, but it includes examples of a first person controller with a machinegun and also cointains examples of inaccuracy, bullet holes and muzzle flashes for the machine gun.

    Project:
    http://www.twiik.net/sites/default/themes/twiikv2/first_person_controller.zip

    Web player:
    http://www.twiik.net/sites/default/themes/twiikv2/first_person_controller.html

    Edit: Fixed broken links
     
  5. angel38

    angel38

    Joined:
    Apr 13, 2009
    Posts:
    100
    I was Happy until I don't found tracer bullets :(

    Thank you for the help man, I appreciate your time.
     
  6. showoff

    showoff

    Joined:
    Apr 28, 2009
    Posts:
    273
    a TwiiK i have a question for u. are u a artist learning programming or a programmer learning to be a artist. i just want to know because some of the stuff ur doing is great and im a artist trying to learn all of this programming and scripting stuff in unity.
     
  7. angel38

    angel38

    Joined:
    Apr 13, 2009
    Posts:
    100
    Showoff, each Game Developer member have a rol in the Team.

    If you are a artist you must to seek programmers, engineer sound, concept Artist and create a team.

    A good game is not building for a person.
     
  8. EducaSoft

    EducaSoft

    Joined:
    Sep 9, 2007
    Posts:
    650
    @Angel38 -> And some people do everything also.
     
  9. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    I'm not sure, maybe I'm neither. :) I started 3d modeling about 2 years ago and have been on and off since then. 3d is a relaxing hobby for me.

    But the things I make in 3d are from blueprints and measurements, I'm no good with the artistic free hand stuff. I can't draw at all and I have no imagination either. :)

    As for programming I started learning PHP about a year ago in relation to work and have been ever since. I also learned some Javascript to be able to create simple effects and such for the websites we make at work.

    I started learning Unityscript about 3 months ago with this project and about a month later I learned enough C# to convert my project to C#.

    Currently I program in Javascript and PHP at work and C# in Unity, but as you can tell I'm very new to programming and all 3 languages. :) However, the PM's I get related to this project make it sound like I'm the one coming up with all these things, but like I've said many times - about 90% of what you see in my project are from tutorials and code examples.

    Angel, the whole point of this project is that I want to learn about everything that goes into making a finished game so I want to do everything myself. That means I have to learn a ton of stuff, but luckily I have no deadline for my game. :)

    Texturing is something I've never done before and that may be the next obstacle I have to overcome on my journey towards a finished game.
     
  10. showoff

    showoff

    Joined:
    Apr 28, 2009
    Posts:
    273
    Angel38 i have been working in the game industry for a few years now and I kind of feel like Twiik. I want to be able to get the feel of what it takes to create a complete game on my own. I know making a game isn't easy and it's a lot of work. I have work for a few small gaming company so I know. I just want to be able to create something of my own that I have to do some of my own coding for because working with when i work with the previews gaming studios we had coders that would always say we couldn't do this or we couldn't do that and they would always blame it on the technology. Now working with unity for a about a month now and i have realize that this is a very powerful engine if use right.

    man that game engine we use was so out data that we couldn't even use blob shadows. It's a shame to say but psp games look better than that crap stuff we release.
     
  11. Discord

    Discord

    Joined:
    Mar 19, 2009
    Posts:
    1,008
    Wow. I really liked the feel of that latest demo. Just curious, when you shoot the gun, are raycasts used and do you just offset them by some random degree? I like how the bullet doesn't just go in a straight line.
     
  12. angel38

    angel38

    Joined:
    Apr 13, 2009
    Posts:
    100
    Well, you use the duck law.

    A duck Swim, fly and run... but...

    a duck don't swim like a fish, don't fly like a eagle and don't run like a cheeta.

    is ok, I agree about learn everything about design of a Videogame, but for a Good, really, really good project you need the best people in your area.

    Twiik, can you put the tracer bullets in the last example? Sorry for bother you...again.
     
  13. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Yes, I use raycasts for the pistol, shotgun and machine gun, but I still use game objects for my bullets. I would never have come up with this on my own, but luckily I disocvered Spk's paintrain thread where he posted an example of doing it this way. This allows for having actual bullet speeds instead of instant hits like you get with raycasts and you can attach models, tracers, particles etc. to your bullet game objects. The "recoil" is just a random rotation which increases the longer you hold the trigger.

    In the demo bullets would sometimes pass through enemies or crates without registering a hit, but I've updated the bullet code locally after uploading the latest build and now I can have the bullets go at nearly infinite speeds without passing through objects.

    A thing I've been wanting to implement is ricochets and bullet penetration. I guess you can use the RayCastAll function for bullet penetration and probably all it takes to get decent looking ricochets is to write an extremely simple "physics"-engine which only calculates angles related to the impact point normal.


    The tracer bullets don't work with the example project because like I said they are just standard trail renderer components attached to my bullets which are game objects. In the example project there are no bullets, just ray casts and instantaneous impacts.

    I may upgrade the project later, but look at what Spk posted in his Paintrain thread to see what my bullet code is based on. My initial version was nearly a straight copy.

    To make tracers just make a simple weapon (take the rocket launcher from the first person shooter tutorial for instance) and replace the rockets with empty game objects with a trail renderer attached. Then copy the settings I showed on the last page and apply the texture I uploaded.

    I believe your duck law theory is flawed. There's no reason one man can't be extremely talented in all areas of game making. Some of my all time favorite games and mods are made by one man.

    The reason AAA games are made by big teams is because its just way to much work for one guy. But there's tons of examples of very impressive indie projects created by one or two guys. And the reason AAA games take so much time these days is mostly to blame on the great looking graphics we all expect. It takes ages to create the high poly models, to texture them, to program the shaders and the graphics engine.

    Compare the graphics of 1 enemy in Gears of War to 1 enemy in Doom. The enemy in doom is just 4 or 5 low res images whereas the enemy in GoW probably has 4-5 much higher res images just for the texture of his rifle. And yet Doom was a lot more fun then than GoW is now. And with a small amount of polish Doom would be even more fun now. And I know Unity and myself can't compete with the graphics of the latest games so state of the art graphics are what I'm focusing the least on, thus saving me a ton of time when making my game(s). That will be my policy: "I make fun, not graphics" =D

    Also if I get some experience with everything now then when I start a bigger project later on I can outsource for example the making of the weapons and I can tell whoever's on the job exactly what format I need the models in and how I want the animations.
     
  14. Armagon

    Armagon

    Joined:
    May 29, 2009
    Posts:
    246
    Hello TwiiK, do you intend sharing this Raycast + Bullet method? it's very interesting.
     
  15. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Sure, here's my entire bullet code:

    If you have looked at Spk's bullet code in his Paintrain thread you will notice mine is heavily based on his. I've basically just removed the parts I didn't understand and replaced a few other parts. :)

    His is surely more advanced and probably better if you can understand it, but a major difference is that I use Physics.Raycast instead of Physics.RaycastAll which he used in the original script.

    I want to be able to use RaycastAll eventually because I'm guessing that will allow me to add proper bullet penetration fairly easily seeing as it returns all hits instead of just the first. So with some clever modification of ranges I can have different penetration depending on the material hit, at least that's the theory. :p
     
  16. Armagon

    Armagon

    Joined:
    May 29, 2009
    Posts:
    246
    Thank you! I'll see if i understand it a little better an will try to convert to JS. :wink:
     
  17. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Here it is in Javascript:

    I can't confirm that it compiles since I did it at work where I don't have Unity, but if it doesn't there's probably only 1 or 2 small errors in there. "Converting" such a script to JS is mostly just replacing all the type definitions with "var" and replacing "void" with "function". :)
     
  18. Jason_DB

    Jason_DB

    Joined:
    Nov 30, 2008
    Posts:
    495
    thats really neat, and I probably sunk about 30 minutes into playing it (got to wave 5). My only advice would be to start on the new enemy types quickly, so that you can start balancing waves more instead of just increasing the amount of enemies.

    I have actually been working on a similar project ( FPS wave defense game), and I have to say that this is very impressive.
     
  19. jojimbo

    jojimbo

    Joined:
    Jun 25, 2009
    Posts:
    37
    wow twiik i missed this,hehehe what an excellent game,fun to play even as it stands :)
    cant beat level7 tho,spent hours on it lol.
     
  20. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Thanks for the comments.

    Most of what you see now are placeholders, obviously, and new and more enemy types will come eventually.

    I've actually changed it to a FPS now, but I won't upload a new version until I have something to show.

    Things I'm working on at the moment:
    - New and cooler effects
    - More effects (different impact effects depending on surface and material)
    - Some bug fixes
    - Variation to everything (multiple muzzle flashes, multiple bullet holes etc.)
    - And a bunch of experiments and tests for fun :)

    Up to this point I've loved everything about Unity, but recently I've been playing with the particle system and to be honest I'm finding it quite lacking. I'm used to the event based and rule based particle systems you find for 3ds max like Particle Flow and Thinking Particles.

    Of course I'm not expecting anything like that, but one thing that's really holding me back is per particle spin/rotation. I guess you could create animated textures of spinning particles, but that's not a very efficient way of doing it and the results won't be as good.

    A simple node based particle system similar to Particle Flow for 3ds max would really rock.
     
  21. Armagon

    Armagon

    Joined:
    May 29, 2009
    Posts:
    246
    Oh, thank you! My JS version was a little different... maybe that's why it wasn't working so well. So much to learn, lol.
     
  22. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,553
    Twiik, how did you code your bullets so they aim exactly at the crosshair?

    I have a problem with a 3rd person shooter I am making:
    http://anomalousunderdog.webs.com/unity/TPSTest.html

    In my test I simply do a ScreenPointToRay raycast using the middle of the screen as coordinates, however when I aim at the sky, of course, the raycast hits nothing so my aim object does not update.

    I tried fixing it by parenting my aim object to the camera so it moves up and down even when the player is aiming at the sky, but its not accurate, the movement doesn't follow the crosshair properly.

    You can test it in the link I gave. A sphere represents the aim object for debug. When you aim at the ground and the cube it works as expected, but when you aim at the sky, the sphere aim object moves too sensitively.

    How did you fix this in your game?
     
  23. MikeDom

    MikeDom

    Joined:
    Jul 2, 2009
    Posts:
    10
    hey mate looks awesome, but could you upload a windows standalone version ?:D
     
  24. stippi

    stippi

    Joined:
    Jun 29, 2009
    Posts:
    4
    Hey.
    Great project! helped me understand Unity a lot more. Is there a chance you could implement your bullet code in the Third Person Test project?

    regards
     
  25. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    I have a raycast going from the camera to the center of the screen and I position a game object at the hit point for the guns to look at. This works exactly like in your example in that it doesn't work if you aim at the sky.

    For that case I take the last known position of the game object (probably the last wall you aimed at before you aimed at the sky) take the distance from the camera to the "target" game object for that last position and just have the game object set at that distance, in the center of the screen, until you look at the ground again.

    It's not perfect because it looks slightly weird when you shoot going from the ground to the sky or vice versa. And because I'm using raycasts it can get very messed up if something comes right in front of the raycast.

    I played and looked at games like Gears of War and Ghost Recon Advanced Warfighter when I was doing the aiming, but I have no idea how they've done the aiming because it doesn't look like it's done with raycasts like in my example.

    In the first person example I just shoot from the center of the screen because there's no projectiles or tracers so there's no need for raycasts.

    I have changed my project to a first person shooter locally now, but I'm still struggling with the aiming. You would think that proper first/third person aiming was something described in detail on any game coding website, but I've been unable to find any help or tips using google.

    The next update I will see how a standalone compares to the webversion and upload what I think works best.

    Do you mean the first person example project I posted earlier? I'll see if I can do it when I have some spare time.
     
  26. MikeDom

    MikeDom

    Joined:
    Jul 2, 2009
    Posts:
    10
    why not upload both ? This way everybody can test them out and tell you which one works faster on diferent rigs. :wink:
     
  27. jojimbo

    jojimbo

    Joined:
    Jun 25, 2009
    Posts:
    37
    Twiik,I got my kids into the game and theyre hooked :D they love it even in its "unfinished" state it has that originality in look and feel,I reckon its a winner as it stands and to add lots of detail and textures,proper modelled monsters etc,might take that uniqueness away.
     
  28. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Mike, we'll see. :)

    That's awesome, jojimbo. This was never meant to become a finished game, but just a project for experimenting and learning so a lot of things will probably change.

    For instance the next update will be first person instead of third person and it may feature some blood so it may not be so kiddy friendly.

    But whatever game I eventually end up making the graphics will be somewhat like what I have now - with detailed effects that stand out from the simple geometry and enemies. I really like that look.
     
  29. jojimbo

    jojimbo

    Joined:
    Jun 25, 2009
    Posts:
    37
    hehe yup,the look of shock/horror as they turn round to see all those things chasing was golden.
     
  30. febrarian2009

    febrarian2009

    Joined:
    Jul 27, 2009
    Posts:
    37
    Wondering if you will post the zip file of the whole unity project as it is in the tutorial section. :roll: lol :D
    But it's fun to play! Awesome idea. :D
    I'll be learning the spawn of pick ups when player dies... Can't get it yet. :)
     
  31. Dexter

    Dexter

    Joined:
    Apr 15, 2009
    Posts:
    104
    @Twiik :
    I agree a lot with what you said on AAA titles and indie games, totally true :)
    Can't imagine how many years would take to one guy to make some game like God Of War 3 :D

    I make fun, not graphics
    That's the best way, even simple graphics can be amazing or have a deep personnality and keep the fun (Legend of Zelda Wind walker, No More Heroes etc . . . )
     
  32. warby

    warby

    Joined:
    Mar 23, 2009
    Posts:
    162
    don't under estimate how much time it took to make the windwaker graphics wouldn't surprise me if the art staff spend more time on that title than on twilight princess !
     
  33. outtoplay

    outtoplay

    Joined:
    Apr 29, 2009
    Posts:
    741
    TwiiK,

    Wonderful project, thanks for all the details, code snippets and sharing spirit.
    Plenty here for this and other code impaired folk to digest and learn from.

    B.
     
  34. angel38

    angel38

    Joined:
    Apr 13, 2009
    Posts:
    100
  35. officergreen2009

    officergreen2009

    Joined:
    Aug 16, 2009
    Posts:
    1
    wow.. you made a great game, very addictive, keep it up. :D
     
  36. MosEisly

    MosEisly

    Joined:
    Oct 17, 2009
    Posts:
    18
    wow!
    i really liked this game!
    simple but fun :)
     
  37. Darrin

    Darrin

    Joined:
    Nov 22, 2009
    Posts:
    5
    I have just begun playing with Unity3D and this project is a great resource.

    I however am having some difficulty connecting the remaining ammo count to a GUItext.

    I attached a part of the script, could someone be so kind as to direct me towards where I am messing up.

    Thanks in advance.
     

    Attached Files:

  38. Jwong

    Jwong

    Joined:
    Dec 3, 2009
    Posts:
    3
    I just started with unity, and I gone through the FPS tutorial. I'm trying to make third person aiming and shooting work, but I have to detach the weapons from the camera to make it look like the character is aiming. Now I'm not moving the weapons vertically anymore. I was wondering how you did it.

    Is it still attached to the camera?
     
  39. Artimese

    Artimese

    Joined:
    Nov 22, 2009
    Posts:
    794
    GREAT prototype, i got to wave 5.. damn it gets hard :p but its very addicting.
     
  40. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Thanks for all the comments and private messages. :wink:

    I've been really busy at work lately and haven't had any time left over for Unity. I have finally installed Unity 2.6 now, which is looking amazing, and will try to get some more time for Unity in the future.

    I didn't even upload the latest build of the project before I stopped working with Unity so there's quite a few changes, features and upgrades in my local build not present in the web player. I will get it uploaded when I have some time to spare.


    I've played Shadowgrounds and games like that is precisely the reason I want to create games of my own. There's so much wasted potential in Shadowgrounds, just like in a ton of other games. I found it to be very mediocre and lackluster in almost every way.


    I'm pretty sure my camera isn't attached to anything and nothing is attached to it. The weapons are all attached to a weapon root node which is attached to my character. The weapon node has a lookAt script to look at the raycast hitpoint cast from the camera.

    The camera is using an orbit camera script if I'm not mistaken. It's either included with Unity or I found it in the scripts wiki or on the forums.


    Web player and files will be available again soon
    I've been getting quite a few private messages about broken links lately and I'm sorry. We're reorganizing a few servers at work and I've taken my site down for the moment.

    This site was just a dev/test site and my live site is hosted on a different server, but that one I've manually set to be unaccessible because it hasn't been updated in years and I'm ashamed of it. I will update it and host my Unity stuff there. Hang on. :)
     
  41. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    Webplayer and files are rehosted and links are fixed
    No changes has been made to the webplayer still and I didn't have time to make any changes to my site so it's still in maintenance mode. :)

    Webplayer and information in the first post: http://forum.unity3d.com/viewtopic.php?t=21381

    I will get the webplayers, projects, files and code snippets organized on my site in a short while as well as start making updates to my project again.

    More to come soon.
     
  42. Paradoks

    Paradoks

    Joined:
    Oct 13, 2009
    Posts:
    436
    thx for the shared stuffs, your work is awesome.
    how did you make the monsters follow you ?
    could you post a tutorial link or something ?

    thanks.

    PARADOKS
     
  43. NoMaD

    NoMaD

    Joined:
    Feb 1, 2010
    Posts:
    41
    Hi, TwiiK. I'm new to Unity and don't know much javascript yet. I really like yor project and trying to build something like that. I have some newbie questions :) . So I made an empty game object, applied bullet script to it and added a trail renderer, also created a box with machinegun script. Made both objects child of FPS controller. So how do I actually make the machinegun object shoot?
    Again saying that I started few days ago without any experience. :oops:
    P.S. : just noticed your example project . I suppose I can find the answer to my question there? :D
     
  44. skinny

    skinny

    Joined:
    Jan 17, 2010
    Posts:
    15
    is there something shared? isnt it just a showcase?
    if i am wrong, then i would love to see how the code manages to make enemies spawn only from places that arent obvious, thus making it great because the player never sees an enemy appear out of nowhere
    (also i would give myself infite ammo on the Artillery ;) )

    great great work!!
     
  45. NoMaD

    NoMaD

    Joined:
    Feb 1, 2010
    Posts:
    41
    Did u use the switch weapon script from FPS tutorial?

    When I use that script with your example project (Added rocket launcher) the machinegun stops making bulletholes and sparks.
     
  46. zhizhi

    zhizhi

    Joined:
    Jan 4, 2010
    Posts:
    7
    perfectly game !
    and really appreciate that you share the coding experiences for us
     
  47. Luis

    Luis

    Joined:
    Dec 4, 2009
    Posts:
    27
    Great learning project! Maybe some animations?
     
  48. Teejay5

    Teejay5

    Joined:
    Feb 26, 2010
    Posts:
    106
    I played your game, and it is excellent and very addictive.
    Could you somehow send me the pistol weapon used in your game? It would be great if I could put it in my project.
     
  49. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    It's been a long time since I've posted in this thread, but I've been working on the project quite regularly lately.

    I was going to not post here until I had a new update ready, but I was bored at work and there was quite a few PM's in my inbox so I bumped it up. Hopefully I can post a new version of the project in a couple of days. There's quite a few cool new features and polish added so it should be fun.

    A ton of workhours however went into modeling detailed weapon models for about a dozen weapon models ranging from pistols, shotguns and rifles to grenade launchers and rocket launchers, but I decided against using them in this project because I'm going for a different style and I have put them in my resource folder for later use. :)

    I've also gone from a 3rd person view to a first person view to a top down view to an isometric view back to a 3rd person view. Quite a bit of time went into that as well, but I learned a lot from it, so it's not all wasted. :D

    Also, my macbook is returned to me so I can test the game on some more mainstream hardware as well as both operating systems. :)

    The enemies spawn from fixed positions at the moment, there's just a lot of possible positions, so there's really no smart logic there. A quick fix could be to just have them spawn from spots which the player can't see (by checking with a raycast).

    Credit for the spawning and wave system should really go to Spk. I've more or less just implemented what he posted here: http://forum.unity3d.com/viewtopic.php?t=21871&start=15

    Yes, I'm using more or less the same script as in the FPS tutorial. I think the only change I've done is that I've moved the fire logic out of the switch weapon script and into each individual weapon. Because some weapons you can fire by holding the fire button and others you fire by clicking it. Not really sure what is causing your problem. It is a long time since I've worked on this and my current implementation of the project is very different from the one online here. Post what you have if you're stilling having problems and I'll look at it.

    Modeling and texturing I'm good at, but rigging and animations I find to be very hard. Also I like coding a lot more than fidling in 3d studio so we'll see. :)

    What do you mean by pistol weapon? Everything that makes it work? I'll see what I have when I get home.
     
  50. Blacklight

    Blacklight

    Joined:
    Dec 6, 2009
    Posts:
    1,241
    This is awsome, but I had difficulty remembering what button gave what weapon, so wasted valuable time and health finding out which one was which. And could you add something that tells the player what their current weapon is by bolding the text or something?