I already have UpdateSceneOffset in code, so this works fine, but I feel like I should be able to do the actual bind in code as well. I can’t find anything about this for some reason. What is the C++ equivalent of this?
One possible solution would be to override the CharacterMovement class and this function, depending on what you’re trying to accomplish, this might be too much work.
You should be able to add OnCharacterMovementUpdated.AddDynamic(this, &AMyCharacter::Something); to the constructor of your character class. This will then call the AMyCharater::Something() function whenever CharacterMovementUpdated is called (or whatever other function you replace “Something” with).
got it! i already had a custom CharacterMovement class from the Shooter Game Sample, so I just added an override for OnMovementUpdated and used it to call a similar function on the owner like so:
I rescind my prior statement. It was far from perfect. It’s hard to say for certain but I suspect that it was only being executed on about half of movement updates. I had to switch back because it was causing more problems than it was worth. DRATS
This seems extremely promising but I’m having some trouble using the AddDynamic function. According to intellisense the closest match is __Internal_AddDynamic which has a different signature: (UserClass*, TBaseDynamicDelagate, FName). Once I type AddDynamic intellisense shows me the signature you’ve suggested, but it will not compile. I’m not totally sure how to make this work. Googling has revealed that the signature was changed in 4.12, but I’m too much of a noob to understand what exactly the solution is.
Intellisense does not always recognize syntax that comes from engine code. You can use AddDynamic by itself if you ignore the Intellisense warning. As for the signature, the signature for OnCharacterMovementUpdated comes from the FCharacterMovementUpdatedSignature delegate, which has the signature of (float DeltaSeconds, FVector OldLocation, FVector OldVelocity). You’ll need to make sure that your function has a matching signature and you should be good to go.
Is the binding being done inside the AVRShooterCharacter class or another class? Additionally, are you adding the binding code inside the constructor? Can you run a test for me by adding the following code to your character class and let me know if you get the debug message during PIE:
I got it working. I had created a function in a parent class called OnMovementUpdated and it was breaking everything. Thanks!
Edit: For whatever reason I also had to bind during PostInitializeComponents when extending the ShooterCharacter from the Shooter Game Sample. I’m not sure why.