10/06/19, 10:06PM Pacific
(60fps Smooth Attack Animations & Bobbing Finished: smooth weapon animations are playable and weapon bobbing is finished; moving on to pre-release work like debugging, optimization.)
- ItemTemplate baseRange Variable (Finished) - I have added a baseRange variable to the itemTemplate file to store an items potential range. Think of this as a value you can use to define the range an item will affect. I'm using this for melee combat, to dynamically assign the reach of each weapon, so weapons have different attack ranges. However, you could use this for anything you need a range value attached to, say a magical affect area or a cast rang or any other possibility you can think of for range; you could assign it to spherecasts to create area affect stuff. You can access this value through the itemHelper.cs script and the getRange() method. You can also access and read it out in UI's using the %ft variable within strings.
- Dynamic Weapon Range (Finished) - Each weapon has a unique float point value assigned to it to simulate a unique attack range. Currently is pulled from itemtemplate through the itemHelper.cs and assigned in the weaponManager.cs anytime you attack. Fists are defaulted to the classic range of 2.25f. Any weapon with 0 range does not show and is broken/bugged. Ensure weapons have a range value of some sort for them to show in fps mode. There is a built in if - then error catcher, but please do not rely on it. Set your base range in your itemtemplate file.
- Debug Raycasting Added: (Finished) - I added a simple unity debug raycasting line into the Weaponmanager script. You will now be able to see the raycast of a weapon attack in the unity engine within the scene window. This is not built into the DF engine, so it will not show up dynamically in game. I do not plan on adding it into the df engine either.
- Dynamic Weapon Stamina Cost (Finished) - Stamina cost for swings is now based on the items weight and range to give weapons more variety and feel. Current formula is simple; ((range+weight)*2). This gives a range of 5 to 17 cost depending on the size and weight of the weapon. Will probably refine formula further later on.
- Dynamic Weapon Speed (Finished) - I have inserted in a public variable into the fpsWeapon script to allow easy manipulation of attack speeds/animations. It can be accessed and set through the fpsWeapon.cs object via .AttackSpeed method. Large weapons feel heavier and slower, small weapons feel lighter and faster.
- Movement Based Attack Types (Finished) - Currently finished a simple movement based attack system. Each strafe key initiates the attack based on that direction. As an example, left strafe = MouseDirection.left. If you're standing still and not moving at all, attacks go back to classic random choice.
- Slower Attack Movement(Finished) - Finished a simple attack movement modifier. You know have your movement reduced by half while attacking. I may try to tie it to the current animation frame to create a more realistic feel to movement while swinging.
- Combat/Unsheathed Stance Slowdown(Finished) - When you go into combat stance/sheathed state, you will move 15% slower, as your more focused on your senses and muscle memory. Sprinting/crouching bonus/debuff will still be applied, but then debuffed by the 15% penalty when in combat/unsheathed mode. So trying to be in a combat stance and sneak at the same time is going to go even slower, as it should. Have you ever tried to sneak while staying in a combat ready, muscle memory, heightened senses state? Yeah, not so easy to do and maintain.
- Weapon Collision Simulation/Feedback(Finished) - DF engine begins sending out raycasts on every frame. Once it hits an object, the raycasts stop. A bool trigger then tells the animation system to replay the animation backwards at an accelerated rate. This simulates a hit and collision. Marking it as finished, but plan on smoothing animations at some point.
- Multiple Raycast Code(Finished) - I have inserted in a coding loop so hit detect raycasts will continually shoot out from the players camera, using the weapons range, to simulate actual weapon swings from beginning to end. Currently raycast stops on first object hit detection. Uses weapons animation time to sync raycast and time their shots (shoots about 30 within a normal animation). As each raycast is shot, a vector transform moves it along a defined axis one small unit at a time. Once an object is hit, raycast stop, fps collision animation begins, and player sets back to idle. Marked as finished, even though I have to refine the vector offsets for the stab and down animations.
- High/Smooth FPS Attack Animations(Finished) - Hijacked animation coroutine, added 12 wait trigger coupled with 12 frame offsets. This gives the appearance of 60fps attack animation *All weapons have been finished.* I've finished all weapon attack animations covering the four base attacks I'm using (left, right, stab, and down). I do need to wrap up fists attacks, redo stab, and do more refinement to minimize a few weapons with noticeable frame skipping, but I'm still marking it as finished. It is in a playable, immersive state.
- Weapon Movement Bob(Finished) -This is supposed to simulate the natural bob running with a weapon would cause. It is tied directly into the frame animation offset variable, which creates nice little side effects, like slower bobbing on stride/run and faster bobs on small movements, like side or back stepping. It works with all weapons, including magical ones and the fists. I'm marking it as finished.
- Unique Item ID Ranges(Started) - I mimicked the weight float point system, as it allows for tons of customization of the value and easy access for ui read outs on the fly. However, to get the system in and tested. I shortcutted the weaponManager.cs script right to the template to retrieve the weapon range instead of creating a unique instance of the weapon and assigning a value to that. This will limit all weapons to their item template value no matter what you do currently. I do plan on implementing the uniqie item range values into weaponcombat.cs later on. This will allow for each item to have custom range values in case any modder ever wants to do interesting things with this value, like create enchantments that increase range.
- Toggle Block(Not Started) - Shields in traditional df had very little benefit. According to thr unofficial wiki and code I have found, shields did very little past adding 1 to 4 armor to you. df unity team added code so it now at least takes armor damage for your arms and hands. However, I wish to add a toggle block similar to modern systems, like skyrim.
- All Weapon Stats Calculate Once/Before All Attack Code: I moved all weapon states and debug message code to run once, right after the weaponManager.cs detects a player attempting an attack. I believe this should stop any bugs having to do with weapon numbers being assigned after the swing and animation code executes.
Weapon Range Code Improvement: Weapon range was original being calculated every frame. This seemed off for multiple reasons. The first being that range was originally set as a unchangeable constant float variable of 2.25f; so, why does the engine need the number continually updated, if it never will change by design. Two, the raycasting code only shoots out one spherical ray on every attack, which pulls the range value to figure out the rays distance; So, why does it need to continually know the range every processed frame? I think this was done originally to allow for dynamic range affects and other mechanics, but they never got to any of it and rammed this constant value in. This ultimately seems like a waste of cpu cycles/frames. I have moved the range value pull from a constant method into the attack boolean trigger. Now, it only grabs this value on every successful attack trigger. This should free up some cpu cycles/frames.
- Added Debug Messages: Needed to know exactly what was happening with the back-end combat system while playing a game for better coding and number tweaking. I have programmed in three different debug messages. One reads out the current weapons range, the next is the current weapons fatigue cost, and the last one will appear when you make contact with an enemy hitbox and verify if you successfully rolled a hit or did not. The last one is critical, as it was hard to know if my code was broken or if I had just missed a hit chance roll in the back-end engine. The first two debug readouts can be found in the weaponManager.cs, right by where it assigns the range and staminafatigue value. The last one is embedded in the formulahelper.cs, way down by the melee hit chance detection code.