Forum begins after the advertisement:
-
::Hi Blog
Basically I’ve tried to recreate the code as well as possible to match what’s in the video but the recoil on the player when it attacks does nothing. I saw a reply about opening debug mode but I don’t know how to do that and even then I’m not sure how to fix the resultant issue.
Something that confused me greatly was that before the recoil section of the video, the player seemed to already have recoil so I was wondering if something was misssed out. Please help
::Hi Witty, have you seen the article for Part 3? If you haven’t, the section on recoil might be helpful: https://blog.terresquall.com/2023/05/creating-a-metroidvania-like-hollow-knight-part-3/#4
As for the recoil on the player, the first thing you want to check is whether the Recoil()
function is being called in the PlayerController when you attack.
void Recoil()
{
Debug.Log("Recoil");
if(pState.recoilingX)
{
if(pState.lookingRight)
{
rb.velocity = new Vector2(-recoilXSpeed, 0);
}
else
{
rb.velocity = new Vector2(recoilXSpeed, 0);
}
}
if(pState.recoilingY)
{
rb.gravityScale = 0;
if (yAxis < 0)
{
rb.velocity = new Vector2(rb.velocity.x, recoilYSpeed);
}
else
{
rb.velocity = new Vector2(rb.velocity.x, -recoilYSpeed);
}
airJumpCounter = 0;
}
else
{
rb.gravityScale = gravity;
}
}
::Hi Terence, it’s funny we had the same thinking and came to the same conclusion, it was the recoil method not being present in the update method that was the issue, I don’t think it was included in the video which was why I was confused. The issue is fixed now and thank you for your help!
Advertisement below: