Download

Why is Character not interacting with boat correctly when possessed.

https://www.youtube.com/watch?v=6hS57ixWjGQ

The other one not being possessed is interacting with boat correctly.
I am using the same pawn. Here is my code.


//Called When Blueprint Is Created
ACoreCharacter::ACoreCharacter()
{
//Set Default Size Of Capsule
GetCapsuleComponent()->InitCapsuleSize(55.f, 96.0f);

//Set Default Movement variables
TurnRate = 45.f;
LookUpRate = 45.f;
MaxWalkSpeed = 600;
MaxSprintSpeed = 900;

// Create Camera Boom
CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
CameraBoom->SetupAttachment(GetMesh());
CameraBoom->bUsePawnControlRotation = true;

// Create Camera | Camera Boom
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
Camera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName);
Camera->bUsePawnControlRotation = false;
}

//Called When Spawned
void ACoreCharacter::BeginPlay()
{
Super::BeginPlay();
SetViewToFirstPerson();
Sprint(false);
}

//Called If Actor Is Possed By A Player
void ACoreCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);

//Bind Jump Input Event
PlayerInputComponent->BindAction("Jump", IE_Pressed, this, &ACoreCharacter::Jump);
PlayerInputComponent->BindAction("Jump", IE_Released, this, &ACoreCharacter::StopJumping);

//Bind Movement Input Event
PlayerInputComponent->BindAxis("MoveForward", this, &ACoreCharacter::MoveForward);
PlayerInputComponent->BindAxis("MoveRight", this, &ACoreCharacter::MoveRight);

//Bind Sprint Input Event
PlayerInputComponent->BindAction("Sprint", IE_Pressed, this, &ACoreCharacter::SprintStart);
PlayerInputComponent->BindAction("Sprint", IE_Released, this, &ACoreCharacter::SprintEnd);

//Bind Sprint Input Event
PlayerInputComponent->BindAction("ToggleView", IE_Pressed, this, &ACoreCharacter::ToggleView);

//Absolute (Mouse) Turn And LookUp Input Event
PlayerInputComponent->BindAxis("Turn", this, &APawn::AddControllerYawInput);
PlayerInputComponent->BindAxis("LookUp", this, &APawn::AddControllerPitchInput);

//Rate Of Change(Joystick) Turn And LookUp INput Event
PlayerInputComponent->BindAxis("TurnRate", this, &ACoreCharacter::TurnAtRate);
PlayerInputComponent->BindAxis("LookUpRate", this, &ACoreCharacter::LookUpAtRate);
}

//Set View To First Person
void ACoreCharacter::SetViewToFirstPerson()
{
CameraBoom->AttachToComponent(GetMesh(), FAttachmentTransformRules::KeepRelativeTransform, "cameraFirstPerson_Socket");
CameraBoom->TargetArmLength = 0;
}

//Set View To Third Person
void ACoreCharacter::SetViewToThirdPerson()
{
CameraBoom->AttachToComponent(GetMesh(), FAttachmentTransformRules::KeepRelativeTransform, "cameraThirdPerson_Socket");
CameraBoom->TargetArmLength = 300;
}

void ACoreCharacter::ToggleView()
{
if (CameraBoom->TargetArmLength == 0)
SetViewToThirdPerson();
else
SetViewToFirstPerson();
}

//Move Forward By A Value
void ACoreCharacter::MoveForward(float Value)
{
Value = FMath::Clamp(Value, -1.0f, 1.0f);
if (Value != 0.0f)
AddMovementInput(GetActorForwardVector(), Value);
}

//Move Right By A Value
void ACoreCharacter::MoveRight(float Value)
{
Value = FMath::Clamp(Value, -1.0f, 1.0f);
if (Value != 0.0f)
AddMovementInput(GetActorRightVector(), Value);
}

//Turn By Value
void ACoreCharacter::TurnAtRate(float Value)
{
AddControllerYawInput(Value * GetWorld()->GetDeltaSeconds());
}

//Look Up By Value
void ACoreCharacter::LookUpAtRate(float Value)
{
AddControllerPitchInput(Value * GetWorld()->GetDeltaSeconds());
}

void ACoreCharacter::Sprint(bool bValue)
{
if (bValue)
GetCharacterMovement()->MaxWalkSpeed = MaxSprintSpeed;
else
GetCharacterMovement()->MaxWalkSpeed = MaxWalkSpeed;
}

void ACoreCharacter::SprintStart()
{
Sprint(true);
}

void ACoreCharacter::SprintEnd()
{
Sprint(false);
}

bool ACoreCharacter::IsSprinting()
{
return GetCharacterMovement()->MaxWalkSpeed == MaxSprintSpeed;
}

Try attaching the character to the boat.