Download

Resize FirstPersonCharacter

Hi

i have a very simple code but i don’t know why i can’t succeed to resize my first person character (the basic one from unreal)

So to explain, I have the FPSCharacter which have an other component named SizeController. And SizeController has to call this when i press the I key. :


this->GetOwner()->GetTransform().SetScale3D(FVector(0.5, 0.5, 0.5));


I have configured unreal to take the input and my character is correctly configured to launch the resize function of the SizeController component:



PlayerInputComponent->BindAxis("Resize", this, &ARescaleCharacter::Resize);


void ARescaleCharacter::Resize(float Value) {
	if (Value != 0) {
		//bool tr = true;
		SC_controller->Resize(true, GetWorld()->GetTimeSeconds());
	}
}

It’s normal if it’s a bindaxis because i can launch the function with I and J.

But When i press I and pass by the setscale function, nothing happen and i don’t know why?

Do you have any idea?
Thanks in advance

When you call GetTransform() you’re actually getting a copy of the actors transform, so any changes you apply to it will have no effect. Use AActor::SetActorScale3D() to change the scale of an actor. Look up the difference between references and values.