Wizard Dev Log 2, Aim Assist
Today’s topic is the Wind Blade spell. It’s deceptively complex, mostly due to my very own aim assist code.
We’ll work backwards for this, starting at the Change Mana event. This is a quick program to change how much mana the player has. It subtracts a specified amount, clamps that integer, and then sets the available mana along with Mana Percent, which a UI element is bonded to.
This change in mana only occurs if an enemy is hit, with this code figuring that out
You can figure out what the Break Hit Result and Apply Damage nodes do. Time to break down what the aim assist does, splitting it into 7 parts.
This first part checks to see if aim assist is even necessary. The Line Trace Dynamic function takes the player’s camera’s location and lowers the vector by 10 units to create the starting point for the line trace. If you remember the fireball’s code, you’ll recognize the next part as the forward rotation is turned into a vector and multiplied by a given float. The new vector is added to the player’s location and used as the end point of the trace. The trace itself has one caveat, where it will only respond to what I consider dynamic objects, such as pawns and projectiles. The hit results are outputted.
Going back to the Aim Assist, the bool which represents if the line trace hits anything determines if a cone trace should be used. The cone is the main tool used in making the aim assist work.
This code might seem familiar, but note that a Multi Sphere Trace is used. The out hits array is fed into a for each loop with break.
Each hit is used to create two vectors, one traveling on the same path a line trace would take and the other going from the start to the hit location. In that collapsed Graph the two vectors are normalized and used to make a dot product, which the arccos is derived from in degrees. I didn’t figure that out because as you may guess, I’m bad with vectors. The degrees of the hit away from the center are printed for testing and compared to the supplied allowance, which for the Wind Blade is 1.5 degrees. If it’s more than the allowance, the next element in the array is computed. If it’s less, the loop is broken. After the loop completes, it looks to see if any of the hits were successful and chooses to give that data or not. This check was added because previously, if there was a final hit outside the degrees, it would still be used. Now on to the second half of the Aim Assist code.
In the time it took me to write this log I changed up the code. Now, if the first trace hits something, it goes into the Line Trace All node. This stops players from shooting through walls. You can imagine what this looks like, but here it is anyway.
If the cone trace is used, a Defined Line Trace All is used for this blockage test. This uses the start and end determined by the cone trace instead of using the camera. It has one extra check that I added because the trace was consistently missing the target by millimeters. It’s another sphere trace but very tiny, to make sure that it’s a real miss.
The final potential outcome for the Aim Assist Trace is a complete miss, not even hitting a wall. This will trigger another Line Trace All, but it’s just to get some variables for if I ever want to add a bullet path, not that I know enough to do that…
Anyway, that’s the Wind Blade. If you have any tips or suggestions, please tell me. I’m very dum.
Wizard Game but bad
It's ultrakill but sucks and with spells
Status | Prototype |
Author | ACultLeader |
Genre | Shooter, Action, Platformer |
Tags | Singleplayer, Unreal Engine |
More posts
- Wizard Dev Log 6, Brick4 days ago
- Wizard Dev Log 5, Random BS20 days ago
- Wizard Dev Log 4, Lightning Bolt20 days ago
- Wizard Dev Log 3, Fireball again24 days ago
- Wizard Game Dev Log 1, Fireball25 days ago
Leave a comment
Log in with itch.io to leave a comment.