[4.2] CharacterMovement frequently crashing my CPP game as it never did before

Dear Friends at Epic,

CharacterMovement is frequently being null in places it never was before in my game code!

I transition from an editor mode, where characters get unpossessed, to a state where they are once again possessed

CharacterMovement is becoming null during this process

Also, my main character’s CharacterMovement is becoming null when I first start the game!

I was relying on CharacterMovement in Tick, and it never crashed before all the way through Beta till 4.1.1

But now in 4.2 I am having to add checks to ensure CharacterMovement is not null in places I never had to before!

Example

The added crash protection below was never ever required before, ever

//During a transition from game to Editor mode where pawn is being unpossessed
//~~~ Movement ~~~
if(CharacterMovement)
{
	CharacterMovement->StopActiveMovement();
	CharacterMovement->Velocity = FVector::ZeroVector;
}

Rama

Hi Rama,

TSubobjectPtrs usually should not be null on an actor, especially never at startup or during game code.

Is it possible that the Character has been marked pending kill somehow? That can cause the pointer access to return null.

I am not deleting any characters while transitioning from editor to game mode, and all the characters still exist after switching back and forth several times.

This one is quite a puzzle, but it never ever ever happened in beta3 through 4.1.1

so it has something to do with 4.2 code changes

I’m not aware of anyone else seeing this, internally or “in the wild”.

Do you have any local engine changes?

It’s also possible that when you Unpossess the character, there is no longer a reference to it, so it is a candidate for GC. However I wouldn’t expect it to tick in that case. A data breakpoint on the character or movement component’s pending kill flag might show you if something is marking it for kill.

"I’m not aware of anyone else seeing this, internally or “in the wild”

Not everyone is making an in-game editor where they frequently unpossess and repossess the main character.

You should dearly consider my issue, because It never ever happened from beta3 to 4.1.1, and I had not done any code changes between 4.1.1 to 4.2 other than formatting to get all the headers happy.

“Do you have any local engine changes?”

no

“Unpossess the character, there is no longer a reference to it, so it is a candidate for GC.”

I was encountering that issue yes, but I found ways to keep the unpossessed character around, and the character is tested and still existing even after multiple switches from editor to game mode.

What is irritating me is that this never happened in beta3 to 4.1.1 ! So I want to know what changed in relation to Character Movement on your side, not mine, since I had no change between 4.1.1 and 4.2 upgrade process to my actual game code.

#Side note

Nice to hear from you Zak! I hope you are having fun today!

Hey Rama, any updates?

One thing I thought of was maybe the changes to the Actor Event Destroyed have changed the behavior of how you are possessing / unpossesing the Pawn. Might be worth looking in to.

Also, have you tried putting a breakpoing in AActor::MarkComponentsAsPendingKill(), to see if for some reason the movement component is being marked for destruction? You could also try hooking up OnComponentDestroyed() on the component to see if that is hit.

Dear Zak,

Thanks for thinking of me Zak!

Sorry I missed you when I was down in Cary :slight_smile:

“One thing I thought of was maybe the changes to the Actor Event Destroyed have changed the behavior of how you are possessing / unpossesing the Pawn. Might be worth looking in to.”

Oooh that’s good to know about, I will keep an eye on that and see if I can figure anything out!

“have you tried putting a breakpoing in AActor::MarkComponentsAsPendingKill(), to see if for some reason the movement component is being marked for destruction? You could also try hooking up OnComponentDestroyed() on the component to see if that is hit.”

this is great debugging info, I will work on this soon as I can Zak!

#My Landscape Collision Fix Plugin

Did you see my landscape collision plugin and videos?!

I found a fix for the landscape collision issues, as a patch, but it works very well for me!

Fun videos here!

:slight_smile: