#Assertion error when adding new Input Action

1 messages · Page 1 of 1 (latest)

lusty dragon
#

howdy guys, complete UE5 noob here. I'm trying to add a simple Sprint input action to the 3rd person template but I get this crash when I do (see pic).

Here's the steps I'm taking:

  1. Adding the new Input Action in the content browser under Content/ThirdPerson/Input/Actions
  2. Adding the new Input Action to the default IMC in Content/ThirdPerson/Input
  3. Copying the Jump action in code (I picked C++ instead of blueprint due to being somewhat familiar with C/C++) - see snippets below.

I'm probably just missing something dumb but can't figure out what it is.

//InvictusCharacter.h
class AInvictusCharacter : public ACharacter
{
    GENERATED_BODY()

    /** Camera boom positioning the camera behind the character */
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
    USpringArmComponent* CameraBoom;

    /** Follow camera */
    UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
    UCameraComponent* FollowCamera;
    
    /** MappingContext */
    UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
    UInputMappingContext* DefaultMappingContext;

    /** Jump Input Action */
    UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
    UInputAction* JumpAction;

    /** Move Input Action */
    UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
    UInputAction* MoveAction;

    /** Look Input Action */
    UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
    UInputAction* LookAction;
        //This is my addition
    UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
    UInputAction* SprintAction;
...
//InvictusCharacter.cpp
...
void AInvictusCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
    // Set up action bindings
    if (UEnhancedInputComponent* EnhancedInputComponent = Cast<UEnhancedInputComponent>(PlayerInputComponent)) {
        
        // Jumping
        EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Started, this, &ACharacter::Jump);
        EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Completed, this, &ACharacter::StopJumping);

        // Moving
        EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AInvictusCharacter::Move);

        // Looking
        EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &AInvictusCharacter::Look);
                //This is my addition - sprinting
        EnhancedInputComponent->BindAction(SprintAction, ETriggerEvent::Started, this, &ACharacter::Jump);
        EnhancedInputComponent->BindAction(SprintAction, ETriggerEvent::Completed, this, &ACharacter::StopJumping);
    }
    else
    {
        UE_LOG(LogTemplateCharacter, Error, TEXT("'%s' Failed to find an Enhanced Input component! This template is built to use the Enhanced Input system. If you intend to use the legacy system, then you will need to update this C++ file."), *GetNameSafe(this));
    }
}
...

As soon as I add/remove the lines in the header file it breaks, removing those lines makes the crash go away. I also tried messing with the character blueprint and found the other IA's but couldn't figure out how to add mine. Thanks in advance!

lusty dragon
#

Am I ok to right click the project in VS and debug from there? Or do I do it from the Unreal editor?

lusty dragon
#

Gotcha, thanks. I’m used to VS but not Unreal

lusty dragon
#

this pretty much solved it. Once I realized that debugging in VS opens the Unreal Editor I understand the proper workflow now. Make changes in code... debug... play around in the editor... etc