Rotation Crashing the Editor

Hi all,

I’m trying to rotate an Actor using a Gamepad Stick. All the bindings are in place and the stick delta value is being correctly. I am using a simple GetActorRotation(), add an amount to the .Roll, and setting it back to the actor with SetActorRotation(). The Actor is rotating correctly up to a certain point where the Editor is crashing.

// Rotation
if (bOrbitActorRotation == true)
{
	FRotator ActorRotation = this->GetActorRotation();
	ActorRotation.Roll += fOrbitActorInputYDelta * 200.0f * DeltaTime;
	this->SetActorRotation(ActorRotation);

        // NOTE: This also crashes the editor with same results
	//FRotator deltaRotation = FRotator(fOrbitActorInputYDelta, 0.0f, 0.0f);
	//AddActorLocalRotation(deltaRotation);
}

I’ve lots of posts regarding Gimbal Lock etc, but none about the editor crashing. Any assistance getting my Actor rotating on it’s pivot would be greatly received.

Kindest regards in advance,
.

Hey fallingbrickwork-

Can you provide the callstack and log files from your crash for additional information? Also, what is fOrbitActorInputYDelta? When I copy the code inside your if statement and place it in the Tick function of MyActor class, the blueprint does rotate as expected in the editor without a crash. If you can provide any additional information about your setup, please let me know to help me reproduce the issue on my end.

Hi ,

Thanks for taking the time to reply.

fOrbitActorInputYDelta is the value coming from my mouse binding:

InputComponent->BindAxis("ObjectViewPivotY", UPIM, &UPlayerInteractionManager::ObjectViewPivotY);

void UPlayerInteractionManager::ObjectViewPivotY(float Value)
{
	if (MyGameInstance->GetUsingGamepad() == false)
	{
		if (bViewingObject == true) Cast<AMM2ActorBase>(CurrentActor)->SetOrbitRotationInputYDelta(Value);
	}
}

link text

You mentioned originally that you are using your gamepad, could you explain how your mouse relates to the issue? Also, looking at the code provided, the first if statement seems to indicate that the call to SetOrbitRotationInputYDelta() is only made if GetUsingGamepad is false (the gamepad is not being used). I’m not sure I fully understand how you’re trying to rotate your object.

Sorry, it’s probably me confusing it. I’m trying to rotate the object with either the gamepad right stick or the mouse Y axis. (I also have bindings for X axis also, but haven’t got the Y working yet)

I have two input bindings:

	InputComponent->BindAxis("ObjectViewPivotY", UPIM, &UPlayerInteractionManager::ObjectViewPivotY);
	InputComponent->BindAxis("ObjectViewPivotYRate", UPIM, &UPlayerInteractionManager::ObjectViewPivotYRate);

void UPlayerInteractionManager::ObjectViewPivotY(float Value)
{
	if (MyGameInstance->GetUsingGamepad() == false)
	{
		if (bViewingObject == true) Cast<AMM2ActorBase>(CurrentActor)->SetOrbitRotationInputYDelta(Value);
	}
}

void UPlayerInteractionManager::ObjectViewPivotYRate(float Value)
{
	if (MyGameInstance->GetUsingGamepad() == true)
	{
		if (bViewingObject == true) Cast<AMM2ActorBase>(CurrentActor)->SetOrbitRotationInputYDelta(Value);
	}
}

The GetUsingGamepad bool is set by the games settings page. So as it stands at the minute both the gamepad and the mouse are having their axis and based on the bool the value is passed into the rotation function in the initial post (fOrbitActorInputYDelta). Both the mouse and the Gamepad are crashing the editor with the same results.

Installed the Editor Debug Symbols… Here is the Crash Summary:

link text

Thanks for the summary, however there is normally an additional line above this that defines what the actual crash was (Access Violation /
Assert Failed / etc.) It should also indicate which line of code crashed. Was there a line like this when the crash occurred?

From what I can see based on the summary, the last call made was to the SetOrbitRotationInputXDelta function. Could you provide the full class for your character where you define the input as well as the actor that’s being rotated?

I think I’ve found the issue… it seems that it is an issue with CurrentActor on this line:

if (bViewingObject == true) Cast<AMM2ActorBase>(CurrentActor)->SetOrbitRotationInputYDelta(Value);

I’ve changed it to…

if (bViewingObject == true) 
		{ 
			if (CurrentActor)
				Cast<AMM2ActorBase>(CurrentActor)->SetOrbitRotationInputYDelta(Value); 
		}

Adding a check to see if CurrentActor is valid and the crash has stopped and the rotation is now working as intended.

I’m just wondering why this would fix it as the CurrentActor can’t be becoming null as the rotation doesn’t stop. My thinking is that if CurrentActor did become a nullptr somehow then this new check would prevent the editor crashing yes but also just stop the actor rotating.

If the editor was crashing immediately when you pressed Play, it’s likely that CurrentActor was being before it was actually set. I’m glad you were able to track down the cause and that the fix was fairly simple.