Can't change CharacterMovementSpeed anymore/ how do I get UCharacterMovementComponent as Variable [C++]

Hello,

right now I’m trying to manipulate the speed of my Character.
Usually this worked:

	GetCharacterMovement()->MaxWalkSpeed = 700.0f;

But after I changed to use two different GameModes for two Levels it doesn’t work anymore.
Is there any connection between my problem and the Gamemodes?
I also tried to set up this code to check the Pointer to the UCharacterMovementComponent but it didn’t work and my Editor crashed.

		UCharacterMovementComponent* movementcomponent = GetCharacterMovement();

Does anybody know a Solution?

With kind regards,

Your question lacks definite details such as what file are you using this code in. Are you calling the code from player controller or game mode? and if you are calling it from the game mode you must get a pointer somehow to the character. Are you using the same player controller on both gamemodes?
Try:
GetCharacter->GetCharacterMovement()->MaxWalkSpeed = 700.0f;

The function gets called from an ACharacter derived class.
I tried to put in your GetCharacter Pointer but there was no reference of it.
Thank you for the answer though

EDIT:
I was actually able to test if the variable is cnahgend over the pointer and it worked out, however, the varaible doesn’t seem to be able to be changed in the actual instance/blueprint. does anybody know what there is to watch out for in terms of settings of the blueprint?
Thanks for the help sofar :smiley:

Quick Info
I was able to solve the problem with a workaround by putting a multiplier at the addMovementInput() function. However, my problem right now is, that variablechanges to the CharacterMovementComponent from any point of the c++ code seem to be applied so that variable is changed but don’t have any affect on the instance of the blueprint. If anybody had the same problem before due to something please help.