Showing posts with label raycast. Show all posts
Showing posts with label raycast. Show all posts

Sunday, 30 June 2024

Melee Working Redux

 

Last Month's Blender Animations Are This Month's Game Animations

I cleaned up my dev folder system, mostly because it had no particular system at all, and was just a mess of folders dumped into a single directory. Over the years this had grown to a somewhat considerable number of test builds, most of which were pointless duplications. Tidy all of this up into a few folders based on simple concepts such as "Game Builds", "Test Builds", "Modules", etc has made everything a lot easier to find.

The only casualty to all of this was the deletion of my Melee Build Test Area, which I had thought was just another test area, however it included some more up to date melee code than the named Melee Project. However it was not particularly advanced so came as no great loss, and whilst redoing the now deleted extra pieces, I actually improved them.

I imported my previously rotoscoped animations into the game engine, and set up a character to use them. With a bit of tinkering all worked as intended, though I have since edited the standard run animation as it contained quite a sharp hip flick which in turn sent the character's butt cheeks into rather a frenzy. This has since been toned down.

Next up was to reinstate hitBoxes to the character limbs. Unfortunately some of the bones rotations had developed a nasty roll , which sent the hitBoxes for the legs into a strange position and so I proceeded to fix this, and annoyingly all the animations which I had previously made had to be redone. Thankfully it was only the legs which needed retuning.

From Hell's Heart I Give You A Good Pokey-Pokey!

HitBox testing worked well, and I even changed the code as to how strikes work. When I had first written the melee code last year, I had for some reason had great trouble trying to get a box mounted on the weapon to use as a strikeBox against the target's hitBoxes, and had in the end settled for an armature bone system to measure between the bones for the length of the attack. 

I say "for some reason" because it all seemed quite straightforward now to set up a box on the weapon for collision, get it's measurement and offset from the handle/mounting point. So the hacky bone node system was retired in favour of the collision box size and offset being automatically stored on datablock preloading. And if there is no box to provide collision for the weapon, it will fallback to using the bounds box and work out it's offset from the mountPoint. So, not sure why all of this proved hugely difficult last year, but I expect "tunnel vision" which seems to happen quite a bit in game development.

The Cold Steel! They Don't Like It Up 'Em!

Expanding the original melee code, which already had a fatigue and rage system, I added stagger depending on how much damage the target had taken versus how much they had remaining. Stagger breaks the target's attack and defence, potentially leaving them open for a free strike. The lower the target's HP, the more they will stagger.

It took a bit of trial and error to prevent the code getting stuck in certain animations, but after a while I ironed out all the obvious bugs. I also rewrote how falling damage works, introducing a plummet system were the player just drops face first, and if damage on impact is high enough a custom plummetDeathAnim plays.

Elden Ring Style Stat Bar Reduction

The player Stat Bars on the GUI got an overhaul, when health or energy is lost the original level is now shown as a different colour and reduces until it meets the current Stat level, a bit like it does in Elden Ring (no I haven't played it, but I am aware it is a thing, and a thing with Stat Bars which do this).

The weapon FSM system got a whole overhaul, and light and heavy attacks now trigger in a way which does not require the player loop to count, freeing up a couple of write/read stream vars. A quick released attack button sets the FSM to interrupt the state and send a light attack var, whilst holding it allows the state to complete for a heavy attack.

There was probably a lot more "stuff" that got done, but I can't remember it all off the top of my head here.


Flaming June was more damp squib June for the second year running, and the strawberry patch appears to have already given up the ghost.

It's halfway through the year already which only goes to show how painfully slow game development is. 😩

Sunday, 30 April 2023

The Dreaded Lurgy

 

 

The Dreaded Lurgy is a Rare SWAG Power-up. It is an Attack Based event which causes the targeted MONSTER to succumb to the Dreaded Lurgy. The infected MONSTER is highly contagious and will transmit the Dreaded Lurgy to any other MONSTER who they come into contact with. However, after receiving the dark gift of the Dreaded Lurgy, the victim is now immune from further infection.

Annoyingly this is also a thing in real life, and I have spent the last month suffering from The Langshan-Po Lurgy - a free internet to anyone who gets the reference, but Gen-X (greatest generation) here, is probably just showing his age.

Needless to say 3D vector maths, gimbals, quaternions, cpp and general cerebral activity, has been somewhat compromised with lurgy brain fog. In celebration at the cerebral degradation - which hopefully will only be temperory - I have revised, both the icon and the in-game activation event art, for
The Dreaded Lurgy.

However during this time, Steam has snuck out a new update to Steamworks (v1.56) ... which broke previous coded SteamGameServer::getAuthentication - thank you Valve devs for the code comments which gave a good explaination of the new changes. 

The Steam update for Monsters Loot Swag is here.

It has also spent all month raining again - just like last month. So it turned out in the end there really was enough rain for April showers. In the midst of all these downpours there has been a frequent visitor, and pidgeon numbers are being reduced.

Who's a pretty boy, then?

In the world of melee combat coding I decided to try a new way of doing things and ended up on some terrible code carousel, going round and round in circles - and having the Dreaded Lurgy did not help brain function. 

I had wanted to look down a list of the target's hitboxes and check if they were within the bounds of a weapon's hitbox. This caused far more problems than I had preceived, with a total lack of being able to get the transforms and orientation of the hitbox meshes within the model. When I could get the hitbox mesh itself it wouldn't allow me to translate it to into world space because it was the wrong class, when I had world space I could not access the hitbox mesh because that was then the wrong class.

I could test a strike against the target bounds and check for intersecting but then to get the actual hitboxes still required using a raycast against all hitboxes to get their transforms and then suddenly we were into more load than I had before.

Dave is made of hitboxes and the raycast is checking alignment of the forearm hitbox

 The only thing I can think of is to create a whole series of points within each of the target's hitboxes and and then check the Box3F of the weapon hitbox against all these points --- and once again we are into even more load, and not the less I was hoping for with just intersection checks of boxes.

Giving all of this up as a bad job, I decided to use the 4 main edges of the weapon hitbox and fire a raycast down each length for more accuracy than a single, central raycast check. This has turned out to be infinitely simpler than going down a list of up to 20 hitboxes checking for intersections.

I also coded up a fatigue system for heavy attacks, sprinting and swimming, and completely rewrote how fall damage works. I started to add attribute statistics for the player, which are fairly similiar to standard RPG stuff with STR, DEX, CON, etc, and the start of a leveling and experience system.

Next up will be to code classes and jobs with bonuses for these attributes on how fast experience points boost them.

Next month I am not certain whether I will continue with the melee action RPG prototype or start porting Monsters Loot Swag to the newest an shiniest version of the engine - I expect it will be a bit of both.

The Dreaded Lurgy is finally subsiding and I am down to a dry and somewhat sore throat with an occaisional dry cough. A pox upon the ... er ... pox!