Download

Change transform of First Person Character with physics and rotation

Changing the position of the character in the scene has been a p* in the a* for the last couple of days.

If you just apply the transform you have, it doesn’t work.

To just **translate **the actor


SetActorTransform(transform) 

Even if you have any rotation on it, it won’t affect the rotation oft he char.

Should I delete all rotation from it? is it affecting at all?. Maybe I should use just SetActorLocation(transform->GetLocation()) ??

To **rotate **it you have to get the Controller


character->GetController()->SetControlRotation(tranfsorm.GetRotation().Rotator());


But my question here is, the physics, even when they are teleported, are not teleported in ROTATION. Just position.

Should I create an Impulse to the character movement? or use any other way to translate that?

I tried this but didn’t work:



FVector oldVelocity = character->GetCharacterMovement()->Velocity;
FVector newVelocity = transform.TransformVector(oldVelocity);
character->GetCharacterMovement()->AddImpulse(newVelocity);


For anybody who needs it. The rotation is not necessary but you can just use the location of that transform to move the char.

The rotation is done with the controller.

And the velocity, is the velocity of the character (GetVelocity()) just like that. It’s better to not AddImpulse to the character, but set the velocity directly .velocity = otherVelocity. So that it doesn’t add anything but replace it completely.