Answer the question
In order to leave comments, you need to log in
How to limit the movement axes of a physical object whose root object is SphereComponent?
There is a class PlayerBall inherited from Pawn with such components
//...
private:
//components
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
UStaticMeshComponent* BallBaseMesh;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
USphereComponent* BallHitSphere;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
USpringArmComponent* BallSpringArm;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))
UCameraComponent* BallCamera;
//functions
void LeftRightMovement(float Value);
//...
APlayerBall::APlayerBall()
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
BallHitSphere = CreateDefaultSubobject<USphereComponent>(TEXT("BallHitSphere"));
RootComponent = BallHitSphere;
BallBaseMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("BallBaseMesh"));
BallBaseMesh->SetupAttachment(RootComponent);
BallSpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("BallSpringArm"));
BallSpringArm->SetupAttachment(RootComponent);
BallCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("BallCamera"));
BallCamera->SetupAttachment(BallSpringArm);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question