When the capsule height of my character I got from Mixamo is the default 88, the character floats. If I change the capsule height to 2, my character is on the ground. However, if it’s 2 then no collisions with the character occur. Like I’m trying to shoot the character with a taser, and it doesn’t hit them unless they’re floating and i shoot the empty air underneath, or if I add a subcomponent mesh to the character. How can I have my character not float, but also have a regular capsule height?
Open up the blueprint with the character. Select it’s skeletal mesh component. If it is floating above the capsule then move it (the skeletal mesh component) down so that the feet are as close to the 0 area in the Z axis (down)
The capsule height should be close to the characters height.
I changed the capsule half height to 100 and it looks like my capsule is rotated. I remember having to rotate my character in C++ because of this.
I also opened the blueprint, but I don’t see the capsule in the blueprint
Thank you for your help.
Probably not a good idea how I did it. I set the rotation in the Tick method. Couldn’t get it working otherwise.
FVector Velocity = GetVelocity();
if (!Velocity.IsNearlyZero())
{
FRotator NewRotation = Velocity.Rotation();
NewRotation.Pitch = GetActorRotation().Pitch;
NewRotation.Roll = GetActorRotation().Roll;
NewRotation.Yaw = NewRotation.Yaw - 90.0f;
SetActorRotation(NewRotation);
}
a) is the default scene root a capsule component? (it’s not even visible in the viewport)
- if so then make it’s height to the height of the character’s skeletal mesh
- change the capsule’s radius to cover the character when it’s in a pose with it’s hands along it’s sides.
b) rotate the skeletal mesh to make it’s forward align with the x axis (red arrow)
Do not rotate the actor. You need to rotate the skeletal mesh component only, for it to be in the correct initial orientation. Disable the rotating code in the tick function.
Ok so it looks like a basic scene component (so an empty offset). It will not give you the same effect as a capsule component
Add a capsule component and move it in the place of the root component.
Then rotate the mesh to align with the forward direction (the axis in the lower left corner of the character preview)
Best thing would be to create a template 3rd person project and look at how it is done by default.
I have a C++ class of an animated character dragged into the viewport. the skeletal mesh is set to the mixamo mesh and also the animation to play. I’m not using the blueprint, it’s all c++. Here are some screenshots of the instance of the C++ class with capsule and skeletal mesh.
Here is a screenshot of the game running.
What should I do? It looks ok in viewport, not in game.
Hey, thanks! I created my capsule in code inside the animated actor class, and set the one in the editor to height 2. I’d like to get rid of the one in the editor, and just have it be in C++, but it’s working now!
In my animated actor constructor:
UCapsuleComponent* CapsuleComp = CreateDefaultSubobject<UCapsuleComponent>(TEXT("PlayerCapsule"));
// Set the size of the capsule
CapsuleComp->SetCapsuleHalfHeight(150.0f);
CapsuleComp->SetCapsuleRadius(34.0f);
// Attach the capsule to the root component (or create the mesh and attach)
CapsuleComp->SetupAttachment(GetRootComponent());
// Center the capsule on the player
CapsuleComp->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f)); // Adjust Z to place properly
// Set collision to be enabled and block appropriate channels
CapsuleComp->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
CapsuleComp->SetCollisionObjectType(ECC_Pawn); // Use the Pawn collision type
CapsuleComp->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Block);
// Optional: Set as root component if required
RootComponent = CapsuleComp;
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.