No announcement yet.

Cover system in UDK

  • Filter
  • Time
  • Show
Clear All
new posts

    Cover system in UDK

    [The code's original author replied to this thread and provided some insight into the code and its shortcomings. His two main concerns are that
    1) The cover system is procedural, meaning that all cover is analyzed at realtime, thereby making it slow, and
    2) The whole system is somewhat unstable, meaning that it's not guaranteed to work as expected.

    As per his request I've updated this post and quoted the relevant part of his post at the bottom. To read his original post, go here]

    Well, I've taken the code written by the guys at ProjectWhite ( and modified it a bit to work with UDK. I've removed a bunch of bugs, added a constraint to camera rotation while in cover, fixed some slightly broken functionality, added a couple of comments, and fixed typos

    What works:
    1. Press "q" to enter cover when near walls or meshes.
    2. The pawn will automatically rotate to press his back to the object that the player is taking cover behind
    3. The pawn will automatically crouch when taking cover behind objects that are not high enough to hide behind when standing straight
    4. Camera rotation is restricted when in cover
    5. The pawn automatically rotates back to normal when peeking around corners to allow players to shoot around them

    What needs to be done:
    1. Blind firing, like in Gears of War. I will implement this a bit later, will update this thread when I do.
    2. Vaulting over low obstacles. Not sure if I can do this, I'm convinced that this will need to be handled via Root Motion.
    3. Animations. I suck at modelling and animating models, so that's up to riggers and animators. Animations have to be made to play while entering cover, exiting cover, peeking around corners. The scripts' original authors have already added support for peeking around corners, but for it to work a bone named SpineControl has to be added to the pawn's SkeletalMesh, among other things.

    The code is kinda huge, so I'm not going to paste it here. I've uploaded it to my site, download link is at the bottom of this post. The file contains the code inside Classes, and all required config files inside Config.

    The code's also too big to explain here, so in addition to the original authors' excellent comments, I've added a few comments of my own. The code is well-commented, I don't think anyone with a reasonable amount of experience will have any trouble modifying it to work for their game.

    There's also some code in there that's unrelated to the cover system, like tilting the camera while strafing and a really cool "lazy" camera for sprinting. I haven't removed it because
    a) It doesn't affect the cover system
    b) You can remove it if you don't want it
    c) It's really, really cool so it might be helpful to others

    Kudos to the scripts' original authors, I've been working on this for four hours and I still haven't quite figured out how all of it fits in together. About 90% of the code in here is their's, all I've done is port it to the UDK, add a few things here and there, and fix some stuff that was broken.

    Note that the original authors have released the code under a Creative Commons License, and I've done the same. While I don't mind what anyone does with my code, remember that if you violate the terms of the license, the authors will have every right to sue you

    Download Link


    ** Edit **
    If anyone is willing to take up any of the remaining tasks (especially the animations) and is willing to share their work with the community, get in touch with me and I'll modify my code, provide you with due credit and update this post accordingly

    ** Edit 2 **
    Added screenshots on my site:

    ** Edit 3 **
    Code's original author quoted:

    Originally posted by dukebag View Post
    I tried to write that code to accommodate almost any surface. Everything is procedural, which means with bigger server loads, it should be SLOW. I did write code in there to scale the number of traces relative to the server frame (attempting optimization). The result is that you *should* see inconsistent behavior when covering. You'll also see tons of config variables; tweaking any one of them the wrong way produces a radically different behavior, sometimes causing things to altogether break. The result is NOT GOOD.

    I'm planning on some rewrite of this code for a newer project, and I'll provide some roadmap of what I already plan to change. Since this was an 8-page thread, I'm inclined to release some version of this code.

    1. Optimize code for straight, non-irregular surfaces only
    a lot of the code was intended to accommodate many circumstances, so there is a lot of error checking for irregular surface normals. that is, you would never normally cover on a cave wall, so reduce it to work only with flat or at least smooth surfaces. Round edges are different, as are basic static meshes. There is potential for doing a 1-time analysis of a wall and generating a movement path. See 2.

    2. seek out any avenues for making this code less procedural
    I'm uncertain, but I've heard with the newest updates there is an ability to make system calls. If that is the case, I plan to circumvent our lack of access to the editor and generate some kind of level geometry file specific to cover (you'd run the map in a wall analysis mode). For instance, if you have played the new Splinter Cell game, generating "next cover walls" would suddenly become very possible. Presently, the way that code finds edges is via 2 traces (1 parallel to your movement, 1 toward the wall you press on). Coding an above peak would work in the same manner. If you tried procedurally to find a potential-next cover wall, you'd be shooting many more traces based on the players FOV. In short, it would not happen. Given some system calls, the game could then write Detailed information about the cover planes.

    So unless there is a way to take this code away from the procedural end, my goal would be to eliminate most of the cases a player is even allowed to cover in.

    Thank you my friend


      WOOHOO!!! Thank you very much! Your the best! Epic Forums is the best!


        thanks a lot YOU ROCK!1


          now we will see lots of GOW like demos....NOOOO


            Originally posted by Hboybowen View Post
            now we will see lots of GOW like demos....NOOOO
            Heeee, come one...


              Well, good on you for releasing code everyone wants but no one wants to learn to write .. *awaits the mass of people going OMG MY GAEM HAZ COVER*


                Originally posted by Blade[UG] View Post
                *awaits the mass of people going OMG MY GAEM HAZ COVER*
                Yeah, that should be a blast to witness


                  someone asked me how to implement stuff like that the other day, and having never played GoW, they sent me a video of GoW to show me how it worked a bit .. . i thought it looked very lame.


                    Yeah, that was my first thought when I saw a video of it the first time. But playing it changed my mind. Anyhow, the cover system in GoW feels kinda clunky, the best one I've experienced so far is in Mass Effect 2


                      Thank You very much


                        It works with the April beta, and should work with the others as well.

                        As for your other question, I'm sorry but I will not answer that. I've subscribed to another thread you've created where you were asking people to post code, and you're not even ready to open a file and take a look at the code inside. All you want is a copy-paste solution. I helped you out in that thread by pasting ready code, and I've put up code in this thread, and you don't even know where to start.

                        In the other thread, Blade[UG] pointed you towards a couple of pages where you could learn Unrealscript, and it's clear that you haven't even taken a look at them, coz if you had then you would know what to do with the Classes directory.


                          maybe i'm just not so much for realism in games that aren't realistic, being a Quake player, but it just looks like a game that would not be fun at all.


                            Gears of War is terribly boring, Only played the first one however. Totally agree with the comment about Mass Effect 2, that has a lovely cover system and is what I origionally thought of when you mentioned vaulting.

                            p.s. love ameyps last post lol, fight the machine !


                              awesome dude, thanks a million