1st Stage - Player Avatar
The assignment requires us to set up character and movement mechanics with animations for each, we were given a link to ‘Mixamo’ website as an option for the character animations. They advertise a lot of free rigging tools and even a character creator, great! even if its a bit generic looking its better than a bright blue mannequin (from the animation-starter-pack in the Unreal store for free).
I logged in, confirmed my email address and everything but for some reason it wouldn't let me download the character creator program, not wanting it to degenerate into another multiple hour long saga, like last time, I guess the starter kit would have to do. (The first thing I did when I had the chance was to change to color to something less eye-wrenching)
I am extremely intimidated by the process of setting up character animations so I immediately turned to the Unreal documentation for the step by step process (awfully nice of them for making this).
At first it was very difficult to understand the blueprint scripting and find all the parts of the graph.
Setting up the Movement blueprint script.
I needed to stop and step through each part of the graph and slowly I was able to get the Lingo. The real test on if I understand is when I try to create my slide mechanic, I understand the basics of calling up variables, comparing and assigning new values, but at this stage I will need to completely map out any new mechanics I want to implement before touching the blueprint graph.
I had seen images of this before and had no idea what it meant, but having it explained step by step, its fairly simple - set the max speed of blend space, then place the animations on the grid so that opposite directions don’t touch.
From here you create the animation state machine, which is just a flow chart of the animations with rules that allow moving from one state to the next.
(rules are usually - when button press = true - when speed = ( or not =) zero)
Creating Slide Mechanic
The first thing I did was to add animations to the state machine flow, because I don’t have the original file, I cant create new animations, so I’m just reusing the prone idle and prone-to-stand. Unfortunately there is no prone-to-crouch set, I thought that you could just play the first half of the animation (stopping at a crouched position to easily blend to a crouch) like you can do in unity, but it seems you cant split animations, you need to re-export them at a different length.
Next was blueprint scripting the mechanic onto the character. The plan was to have the slide behave like this:
- hold space to slide, releasing space stops sliding and stands up
fairly simple, created a release option for the space bar the resets everything
- cant change directions while sliding
at start of slide, disable movement, also created a variable to disable turning
- speed boost at start, slowly comes to a stop
This was a bit difficult, at first I tried having the slide behave like a jump, goes up into the air then falls on the ground with the prone animation but this didn’t work, the character would barely hop.
Then i tried just increasing the movement speed to have it slow to a stop, I could get the first part but had to turn to the internet to find out how to make the character decelerate. I could only find some convoluted way of increasing the friction over a timeline or something, but this gave me an idea, why not have an initial force push the character and lower the friction temporarily so the character slides to a slow stop.
I would show the graph but its fairly long and you wouldn't be able to read it when it’s shrunk that small but here is the run down in words.
event-on-jump -> if crouched = true -> set character-max-speed to zero -> make ground friction 1/40 strength -> Launch character at current direction at current speed times 7 -> disable turning
event-on-release -> set character-max-speed to (crouch speed) -> make ground friction 40 times strength -> disable character movement for half a second (while standing up) -> re-enable movement -> re-enable turning
So by the end we have
- Idle (no input)
- Walk (wasd)
- Run (hold left shift)
- Crouch (toggle left ctrl)
- Turn (mouse movement)
- Jump (space-bar)
- Slide/dive (ctrl toggle on + space bar)
Overall using blueprint scripting has been interesting
It can get confusing, the usual ‘IF’ ‘WHEN’ ‘FOR X’ is nowhere in sight instead is a flow chart. I don't know if it was just the tutorials that i was using, but the lack of the ability to create global variables leads to placing absolute values in logic boxes (bad practice).
On the plus side, I like the flow chart aspect of this OOP style, it helps visualize the function’s progression and its colorful :)