Today’s implementation:
Roll and jump redesign
According to the design of Black Soul games, jumping can only take off when running, and it is accompanied by tumbling action. That is to say, the active jumping function we designed before is not available in Black Soul games. Our design needs to be changed.
The current design is to replace the jump button with the roll button, so that the roll button replaces the jump, and the only way to jump is to press the roll button when running, and roll when landing.
Flip animation and trigger logic
This is a scroll forward animation, which needs to bake the Y axis of the animation into pose.
Add animation directly to the animator. Rollover occurs when the player actively presses the rollover button and switches directly back to ground.
The transition condition is that when the player presses the Roll key (originally the jump key), the animator parameter roll is triggered. The trigger of roll tells the animator to make the conversion.
Since ground can transition to multiple other animation states, priority is important. In conjunction with the relevant codes for roll and jump, the priorities are as follows.
The code related to roll and jump is as follows. First, the input must be closed like the jump before roll, and the plane movement is locked.
Public void OnRollEnter() {// Close the input and lock the plane movement DisableInput_LockPlanar(); }Copy the code
Finally, the trigger code for roll.
If (pi.roll) m_im.settrigger ("roll");Copy the code
The forward momentum of tumbling
Since rolling locks up flat motion, we need a roll impulse to make the animation look less weird (the displacement doesn’t match the animation). At present, our plan is to adjust the plane movement quantity to the normalized plane movement vector multiplied by the roll impulse after locking, so that the roll displacement of walking and running will be exactly the same. A better idea would be to animate different rolls at different speeds (walking and running), which would allow us to set different speeds for both walks and runs.
Public float rollThrust= 2.0f; Public void OnRollEnter() {// Close the input and lock the plane movement DisableInput_LockPlanar(); M_planarVec = m_planarVec. Normalized * rollThrust; }Copy the code
Jump and roll forward
As mentioned earlier, you can only jump by pressing the roll button while running. Jumps are still triggered by the jump parameter. Note the conversion priority.
The trigger code is as follows.
If (pi.run && pi.roll) m_im.settrigger ("jump"); // If (pi.run && pi.roll) m_im.settrigger ("jump");Copy the code