Third person shooter - Learning project

Hi everyone.

This is my first Unity project, about 20 hours in the making. :smile:

Eventually (hopefully) it will be a multiplayer quake 3 style shooter with a game mode which lets you play cooperatively against waves of enemies.

New version uploaded

Click the title, image or here to try it out.

It may be a bit resource hungry, I donā€™t know because Iā€™m getting about 1000fps on my beast machine. A more conservative system may struggle some as I set the settings to fantastic.

Iā€™m using just primitive geometry as well as assets from different tutorials because I donā€™t want to spend time modeling and texturing when I could spend that time learning Unity.

I thought Iā€™d post my game here to get help, information and input from the community while I worked on it. And I think itā€™s fun already so maybe you do as well. :wink:

Controls
Control character: WASD or directional keys
Control camera: Mouse
Control time: Scrollwheel
Jump: Spacebar
Shoot: Left Mousebutton or CTRL
Different weapons: Numeric keys (1-6)
Show cursor / pause game: ESC

Iā€™ve been a long time lurker here, but waited for 2.5 before actually going past just opening Unity. We have 1 or 2 copies of Unity Indie at work and even though weā€™ve never had the time to use them they are all bound to different macs so Iā€™m using the trial version at the moment.

I have nearly zero programming experience and when I started this project I had barely opened Unity before, yet I havenā€™t gotten stuck a single time. If I wanted something in my game I have been able to create it or piece it together from snippets found on the web. It is just so beginner friendly. :slight_smile:

There is of course quite a bit of code taken from the different tutorials on this site, and many of the assets are from the same tutorials or commercial games and mods, but seeing as this is a learning project I didnā€™t mind and I doubt anyone else will either. :slight_smile:

I have made quite a bit of maps and smaller mods for different Unreal games, Crysis and Half-life 1 and 2 and I feel the tools in Unity can easily rival those supplied with many of those games. And the Unity interface is one of the most intuitive and easy to learn Iā€™ve encountered.

Sorry for the ramble.

Things Iā€™m planning to implement into the game in the weeks to come:

  • Levels with enemies which progressively get harder (added)
  • More enemy types (added)
  • More weapon types (added)
  • Better AI
  • Maybe even some assets of my own :slight_smile:
  • Textures
  • Multiplayer

More to come. I will just overwrite the existing web player when I make changes, except if they are something very experimental.

Edit: Updated the links to point to the latest version.

Edit2: Updated some information to reflect changes in the latest update.

Edit3: Fixed the broken links resulting from my server transfer and updated some information

Edit3: Changed some information to reflect changes in latest update.

Edit4: Edited the links to the game

Great little prototype. A lot of fun.

Thatā€™s indeed pretty cool for a prototype! Would be even more fun as ā€œmultiplayerā€ :stuck_out_tongue:

Thomas

Wow, nice work! Do post your regular updates. Iā€™m watching this topic :slight_smile:

Very nice little prototype. I think youā€™ve got a handle on most of the problems, but Iā€™ll go ahead and let you know mine (it is the interweb afterall :wink: )

  1. Cursorā€™s hard to read, especially at distance, making for many missed shots.

  2. The gun is on the side of the character, but expectation is that the weapon would fire towards the center of the character.

  3. Everything having the same texture means things get lost (walls, enemies, floor, etc).

  4. The camera seems pretty high for a 3rd person shooter. If it were a 3rd person brawler of adventure/platformer, Iā€™d say it was ok, but too high for a shooter.

  5. Needs a HUD, so I know how much health I have.

Like I said, really awesome prototype. I wish I had something as cool after 20 days, let alone 20 hours (my day job is unnecessarily demanding and unfortunately in the same field as my ā€œhobbyā€).

Iā€™ve played it on my laptop; Intel duo core 2.17ghz / 2gb ram :cry: / Some Intel integrated crap graphics card. I was getting ~24fps most of the time. Iā€™m impressed it was that high considering youā€™re using physics objects for the tracers versus a raycast and some grfx jiggery-pokery.

You mentioned you had NO programming experience, but worked on mods. Do you have Kismet experience?

Anyway, Great work! Keep us posted. I look forward to your next rev (also inspires me to get off my lazy ass and do something b4 my 30-day trial is up!)

Haha, me too. Unfortunately I canā€™t come up with any ideas, or at least, something Iā€™m capable of.

Great prototype TwiiK! Only thing I donā€™t like is how hard is to aim, especially at those turrets. Keep it up and soon youā€™ll have a pretty cool little game :slight_smile:

Very nice. Reminds me of the recent postā€¦

http://forum.unity3d.com/viewtopic.php?t=20074

You donā€™t need crazy graphics to make an epic game.

I like it so far. Itā€™s fun to play, and relatively simple. You have the core gameplay very well done, thatā€™s a good thing to focus on tooā€¦ (I learned that the hard way :smile: )

A few things I recommend thoughā€¦ you should try to do an over-the-shoulder view for the player, much like many more modern 3rd person shooters, where the camera is positioned directly over the playerā€™s gun. This makes it much easier to aim, see the picture below if you donā€™t understand what Iā€™m rambling about.

Role is very cute :smile:

Thanks for the nice comments. :slight_smile:

I made a small update to the game which includes:

  • Plasma bolts now detonate on collision with an enemy
  • Laser Sight can be enabled/disabled with the ā€œeā€ key on the keyboard
  • Proper HUD crosshair
  • Better aiming. The guns now aim towards a raycast hitpoint instead of just straight ahead.
  • Simple developer textures just to make it look a little nicer
  • New and bigger level layout

Thatā€™s about it.

You can find it here or in my first post: http://www.twiik.net/sites/default/themes/twiikv2/twiikashoot_new.html

Still experimenting with the camera and itā€™s still quite buggy. I loaded up Gears of War after reading Maxwelldoggumsā€™s comment and tried out a similar camera viewpoint, but the pivot needs to be changed or something. I think I want the camear a little further away.

Didnā€™t have time to make some bigger changes, but I will try to squeeze in some time tomorrow.

[quote]
Do you have Kismet experience?
[/quote] No, thatā€™s for UE3, right? I havenā€™t had the chance to play with that and now that I have Unity I doubt I ever will. :slight_smile:

Btw, I think Unity seriously needs some better scene edit tools. Like grid snap, angle snap, vertex snap etc.

The new level is grid based mainly just to keep things neat, but also in case I want to make a random level generator later on. And it was a little tiresome aligning things with no form for snapping.

Edit: Fixed broken link

Those ā€œdeveloperā€ textures look super familiar to me :stuck_out_tongue: Nice update Twiik! Keep at itā€¦ I like what youā€™re doing here.

Thomas

The new textures and aiming make it a bit easier.

Just one problem: the 3rd person push bodies. I try to go up the box stairs, and I push them over, and canā€™t get up. Then, I canā€™t get the boxes back up, and I canā€™t finish the game. :frowning: Can you somehow make that less of an issue?? Please?

Pretty awesome, anyways you say it, though.

There is nothing to finish at the moment. :slight_smile:

There may be a goal of some sort next update.

I think I actually made my own pushbodies script because I didnā€™t find the included one. I saw the thirdpersonpushbodies script yesterday, but forgot about it. I will check it out and tweak the one that works best in a future update.

Hehe, Thomas, buying your tutorials has to have some advantages, right? :slight_smile:

I remember loving the developer textures in the Hammer editor for Half-life 2, but was unable to extract them. Then I remember you had some great ones as well so I put those in there. :wink:

The level as it is now is just cubes in different sizes created in the editor. I may try to model a similar scene in 3ds max to try out lightmapping and some other things at the same time.

A very tiny update and quite a few problems. :slight_smile:

Iā€™ve added bullet hole decals to the machine gun and changed the camera. Well, at least I spent quite a few hours trying to change the camera, but Iā€™m struggling.

Hereā€™s the latest version:
http://www.twiik.net/sites/default/themes/twiikv2/twiikashoot_new.html

I played some Gears of War, Ghost Recon, GTA 4 and Dead Space to look at their third person cameras and they all use more or less the same system:

  • The camera pivots around the character at shoulder height
  • The controls are exactly like a first person shooter
  • The weapons aim at a crosshair in the center of the screen

I want a similar camera in my game and I feel Iā€™m getting very close, but Iā€™m facing a few issues.

In the current build Iā€™m using the OrbitCamera script I found in the third person tutorial on the main camera. The player himself is controlled by a first person controller and I attached a small script to the weapons which gives them the same rotation as the camera.

Everything is great except the camera doesnā€™t move with the player when he rotates. It just rotates around itself. So if you rotate 180 degrees the camera is on the playerā€™s left side instead of his right. It should have the same postion relative to the player all the time, but Iā€™m unable to make that happen.

Also, the weapons miss their mark.

Iā€™ve tried countless variations where the camera raycasts a ray, the player raycasts a ray, different camera scripts, variations where the weapons look at the ray hit, variations where the player looks at the ray hit etc. Written different camera scripts and googled my brains out, but Iā€™m not not getting it as I want it. What I have now is probably as close as Iā€™ve gotten.

My problem with using a raycast is that when you aim at the sky it doesnā€™t hit anything and thus the player wonā€™t aim higher than the highest wall which was last hit.

Hereā€™s the blunt of the orbitcamera script:

function LateUpdate () {
    if (target) {
        x += Input.GetAxis("Mouse X") * xSpeed * 0.02;
        y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02;
 		
 		y = ClampAngle(y, yMinLimit, yMaxLimit);
 		       
        var rotation = Quaternion.Euler(y, x, 0);
        var targetPos = target.position + targetOffset;
        var direction = rotation * -Vector3.forward;
		
        var targetDistance = AdjustLineOfSight(targetPos, direction);
		currentDistance = Mathf.SmoothDamp(currentDistance, targetDistance, distanceVelocity, closerSnapLag * .3);
        
        transform.rotation = rotation;
        transform.position = targetPos + direction * currentDistance;
    }
}

currentDistanse is the offset value for how far away from itā€™s pivot point the camera should be.

The player is the target.

The camera is parented to the player object and what I would guess should be in the code somwhere is transform.localPosition to ensure that the camera stays where it should relative to the player, but whenever I try putting localPosition in there it messed it up completely.

I may just be tired and the solution may be obvious, but Iā€™m asking this question so I may wake up to some helpful input in the morning. :wink:

Anyone able to lend a helping hand? :slight_smile:

Edit: Fixed broken links and removed outdated dynamic shadows version

the gun goes around in circles now with the new update and you donā€™t know were your shooting. otherwise this project is create 8)

New update:

  • Added a HUD (finally managed to make it not crash my game at random :smile:)
  • Completely rewritten my way of handling ammo allowing me to have easily manageable pickups etc.
  • Added a new weapon: Guided missile launcher (very bugged, but kind of fun :)) Select it with ā€œ4ā€
  • Added 1 ammo pickup type for each weapon, and randomely scattered a bunch of them around the level
  • Changed the camera again and reverted the aiming to raycasting (introducing new bugs and issues and removing old ones)
  • Enemies can now drop fuelCells as well as health. The fuelCells donā€™t do squat at the moment except reduce the Items counter in the lower right corner :slight_smile: (I actually forgot to disable it before I built the game and Iā€™m to lazy to reupload it) The fuelCells will be some kind of currency or similar in a later update.

Try it out here:
http://www.twiik.net/sites/default/themes/twiikv2/twiikashoot_new.html

I didnā€™t overwrite the old version of the game this time so if anyone wants to help me with my camera issues you can have a look at my last used camera system in my last post.

As evident in both the player controls and especially the guided missile controls Iā€™m really struggling with the game camera in Unity. :? I suspect itā€™s the vectors and especially the quaternions that are confusing me. Iā€™ve had to brush up on my vectors a few times already, but the quaternions Iā€™m having a harder time with.

Still no goal or purpose to the game, but maybe in the next update. :slight_smile:

very funny

the plasma ball has the sound of the portal energy balls hehehehe :lol:

nice work

Very nice update Twikk. I like the missileā€¦especially that you can ā€œfly/target/navigateā€ it :smile: I am happy to see that you not only take the dev textures from my video training but you seem to model your levels according to what I teach (If I am not mistaken here). Correct me if I am wrong though :slight_smile:

Maybe we can do something together in the future (short little FPS perhaps?) :wink:

Thomas

Well done, It is fun!

Once the enemies see me they block me into a corner and I canā€™t move so I just sit there and die. Maybe you can make the enemies stop at a reasonable distance and start firing so the player has a chance to escape.

Iā€™ll be looking for the updates to this.

Cheers,

Josh

How did you create the bullet holes? are they decals?

Yep, I believe so!

Probably could get some ideas for the required code from the splatter demoā€¦ Itā€™s here in the forum somewhere.