RPG => 3rd Person tutorial chap 26 Impossible to move after pickingup an item

Hello Brian.

I finished the chapter 26 according pickup up item on the floor.

It works for me with the left mouse button.

The item desapear exactly has expected at the exact moment of the animation.

The item is in my inventory :

But i’m completly unable to move after picking the item.

I can only move the camera with the mouse.

And for one time… I haven’t any error message lol :slight_smile:

Any Idea?

Thanks.

François

It sounds like after picking up the item/closing the inventory window that you’re not changing the State to a new PlayerFreelookState…

Hello Brian.

I’ve the method in the PlayerFreelookState.cs file:

        private void InputReader_HandlePickupEvent()
        {
            if (stateMachine.PickupFinder.GetNearestPickup() != null)
            {
                stateMachine.SwitchState(new PlayerPickupState(stateMachine, stateMachine.PickupFinder.CurrentTarget));
            }
        }

I noticed in your final repo you created another one to switch called “FindNearestTarget” and not “GetNearestPickup” as actually in the GitHub.

I have the PickupEvent on the enter method:

        public override void Enter()
        {
            stateMachine.InputReader.JumpEvent += InputReader_HandleJumpEvent;
            stateMachine.InputReader.TargetEvent += InputReader_HandleTargetEvent;
            stateMachine.InputReader.PickupEvent += InputReader_HandlePickupEvent;
            stateMachine.Animator.CrossFadeInFixedTime(FreeLookBlendTreeHash, stateMachine.CrossFadeDuration);
        }

And in the Exit method:

        public override void Exit()
        {
            stateMachine.InputReader.JumpEvent -= InputReader_HandleJumpEvent;
            stateMachine.InputReader.TargetEvent -= InputReader_HandleTargetEvent;
            stateMachine.InputReader.PickupEvent -= InputReader_HandlePickupEvent;
        }

I go to keep on and see if it’s fixed later on your course.

François

I had to do a little digging to see what was going on here.
At the point of Pickup, I did use GetNearestPickup(), but as we start to add new RangeFinder based classes (Conversants, Shops), you’ll notice that there’s a lot of duplicate code.

FineNearestTarget() is at the RangeFinder level, and regardless of the type of RangeFinder, it will select the nearest target and return true if that was possible, or false if there are no targets within the Targeter. It’s introduced in the entry Shopping Spree

Hello Brian.

I replaced all method “GetNearest…” by the FindNearestTarget in rangeFinder.

At the end of chapter 29, the Shop challenge you override the onDisable method in the ShopUI.cs script but visual studio tell me there is an error.

WindowController.OnDisable is unreachable due is level of protection.

Effectivly, in the WindowController.cs script, the OnDisable method is in private.

I had protected virtual in front of it.

But at the end it doesn’t fix my moving problem after pickingup an item.

And acctually my Shop doesn’t work as it must.

It doesn’t open…

Strange..

Schusss

François

We’re dealing with two different mechanics through this topic…

PlayerPickupState should be returning to PlayerFreelookState() when the Normalized time (GetNormalizedTime()) is greater than 0.8f

Now there is a bug I mentioned later in the Pickup lecture, in that it turns you DO have to specify the tag to get the GetNormalizedTime to work properly. So I changed the base GetNormalizedTime to take an optional parameter

        protected float GetNormalizedTime(string tag = "Attack")
        {
            var currentInfo= stateMachine.Animator.GetCurrentAnimatorStateInfo(0);
            var nextInfo = stateMachine.Animator.GetNextAnimatorStateInfo(0);
            if (stateMachine.Animator.IsInTransition(0) && nextInfo.IsTag(tag))
            {
                return nextInfo.normalizedTime;
            }
            else if(!stateMachine.Animator.IsInTransition(0) && currentInfo.IsTag(tag))
            {
                return currentInfo.normalizedTime;
            }

            return 0;
        }

This means you need to make sure that you call GetNormalizedTime with a parameter like “Pickup” and your Pickup animation state in the Animator needs a “Pickup” tag for the Normalized time to work properly.

For the shop… was the Dialogue window working correctly?

HeHello Brian.

Thanks for your feedback.

I’ll rest the new getnormalized method on thuesday when’ll be back from Croatia.

And yes, my conversation works perfectly.

Thank you for your help.

Take care.

François

Hello Brian.

So first good new, My shop interaction work perfectly, using left mouse button…

I let too much time between two courses and forgot I implemented B key instead of left mouse button in the input system…

Sorry for that.

But for my pickup event, I already added your code to fix the bug.

The only thing I haven’t done is add a tag called Pickup to my Pickup State in the animator.

My StringHash name for pickup is Pickup Bottom.

private static readonly int PickupHash = Animator.StringToHash("Pickup Floor");

Because I plane to have 3 differents pickup animation, depending where the pick is (the height).

So I added Pickup Tag to the animation in the animator window:

But nothing change. I’m steel blocking after pikingup the item.

All my actual attacks have the Tag Attack.

I must admit I’ve a doubt according Pickup tag.

Where is it called ?

Does I have a conflict between my differents name according pickup?

Thanks

François