UnityTechnologies / open-project-1

Unity Open Project #1: Chop Chop
http://unity.com/open-projects
Apache License 2.0
5.73k stars 2.03k forks source link

The Slime Critter attack throws the player several meters away #349

Closed Eddrico closed 3 years ago

Eddrico commented 3 years ago

Short description When the slime critter attacks and the player jumps, the inertia of the attack is transferred to the player, throwing the player several meters away.

Expected behavior The attack should not push the player so far.

To Reproduce Steps to reproduce the behavior:

1.- Open a scene with the TestingGround. Press play.
2.- Get near a Slime Critter and wait for his attack.
3.- When the attack is about to connect, press the jump button.
4.- Observe that the player is sent flying away.

Notes

Here's a video of the issue:

https://www.youtube.com/watch?v=pnKQh3bKC8Y

ciro-unity commented 3 years ago

Forum link: https://forum.unity.com/threads/the-slime-critter-attack-throws-the-player-several-meters-away.1050692/

treivize commented 3 years ago

For this one, I would suggest to wait for the coming PR about combat system to be merged before starting to solve it. Jumping will be prevent when the player is getting hit by the slime critter attack, so this bug should not be reproduceable after the integration of this part of the system.

ciro-unity commented 3 years ago

The issue doesn't happen because the player jumps. It just happens when it's squashed by the attack against a rock or wall.

I actually made a video of it some time ago:

https://youtu.be/aQ9KuTuTNbM

I'm not jumping at all here!

treivize commented 3 years ago

Indeed, but are you able to reproduce it now that the player is really getting hit by the critter? I have just tried multiple times to reproduce it without success.

ciro-unity commented 3 years ago

No I don't think so. The initial description can throw you off guard: it's not that the inertia is transferred (I think) since the player has no Rigidbody. Most probably what was happening is that the Critter would move into the player -> Next frame the player is pushed out (as would two colliders one inside the other). But now that the Hit is implemented, the player instantly plays an animation which keeps it anchored to the spot it is (root motion?) so it doesn't fly away. Why doesn't he fly away after the animation is done, I'm not sure. (these are all guesses)

In any case, no, I don't generally see it now. I will check again for some time, then close.

AlexandreGheraibia commented 3 years ago

Maybe because in StopMovementActionSO called by Idle you have:

public override void OnUpdate()
    {
        if (OriginSO.Moment == SpecificMoment.OnUpdate)
            _protagonist.movementVector = Vector3.zero;
    }

    public override void OnStateEnter()
    {
        if (OriginSO.Moment == SpecificMoment.OnStateEnter)
            _protagonist.movementVector = Vector3.zero;
    }

    public override void OnStateExit()
    {
        if (OriginSO.Moment == SpecificMoment.OnStateExit)
            _protagonist.movementVector = Vector3.zero;
    }

And in ApplyMovementVectorActionSO also called by Idle you have :

public override void OnUpdate()
{
        _characterController.Move(_protagonistScript.movementVector * Time.deltaTime);
        _protagonistScript.movementVector = _characterController.velocity;
}
AlexandreGheraibia commented 3 years ago

Velocity ​​is zero when you update idle state

r4hulCorleone commented 3 years ago

Hi, as i informed in unity forum, I like to work on this bug, producing the bug was hard for me because i need better timing, so i wrote a simple code that player does a jump action with delay after critter starts to attack, and with a proper delay, i reproduced the bug when player jumps successfully for a lot of times. I will search for the root of this bug, i think @AlexandreGheraibia comment is a good start point for me. i will notify you when i find out more about the bug.

amel-unity commented 3 years ago

Hey everyone! Is anyone still able to reproduce the issue on the current main branch? If yes, can you please make a video? I tried to reproduce it but it seems like it is fixed. Thanks!

amel-unity commented 3 years ago

Looks like the issue has been fixed so I will close it just to avoid that anyone spends time looking into fixing it. Thank you all :)