Announcement

Collapse
No announcement yet.

Changing movement modes using custom movement component

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Changing movement modes using custom movement component

    Hello!

    I needed hanging custom movement mode for my game and probably need some more movement modes, so I created a new movement component which inherits from
    UCharacterMovementComponent.

    I set up my custom movement component using ObjectInitalizer which is shown on the next line:

    AGameCharacter::AGameCharacter(const FObjectInitializer& ObjectInitializer) :
    Super(ObjectInitializer.SetDefaultSubobjectClass<UGameCharacterMovementComponent>(ACharacter::CharacterMovementComponentName))
    {
    ...
    }

    For next, I had SetMovementMode function and PhysCustom function both overridden. In SetMovementMode function I can do the setup for my hanging custom movement mode as shown in the following line:

    void UGameCharacterMovementComponent::SetMovementMode(EMovementMode NewMovementMode, uint8 NewCustomMode)
    {
    Super::SetMovementMode(NewMovementMode, NewCustomMode);
    if (NewMovementMode == EMovementMode::MOVE_Custom && NewCustomMode == (uint8)ECustomMovementModes::MOVE_Hang)
    {
    //TODO
    }
    }

    And I am not aware what PhysCustom function is for, many threads suggested overriding it.


    However, the problem is - whenever I change my movement mode to custom movement mode such as hanging and in my jump function for example I want to change the movement mode to falling, the movement mode won't update itself anymore and it will stay in Falling movement mode.
    When I print out movement mode continously and jump afterwards it will change between Falling and Walking, but the character will always stay on ground.

    I am not sure what I should do to overcome this problem as I can't find much information on the internet.

    Looking forward to your reply,
    With regards


    EDIT: Even when switching between non-custom movement modes, the movement modes won't change properly. I believe the problem is somewhere in the new custom movement component.
    Last edited by Rasponien; 10-11-2017, 04:49 AM.

    #2
    I am not overly sure, but might the problem be that I basically added a new State and I don't have to transition lines between the added state and already existing ones? Although when I change movement mode to falling, the transition should be clear that at some point the next movement mode is walking?

    Or I understand this terribly wrong.

    Comment

    Working...
    X