I’m new UE and C++ , due to limited knowledge I couldn’t do it myself ,and hoping help from some experienced person to help me rebranding this problem.
In this video below can explain ,How this blueprint works.
I’m new UE and C++ , due to limited knowledge I couldn’t do it myself ,and hoping help from some experienced person to help me rebranding this problem.
What difficulty are you having? The InputTouch specifically, just create 2 functions and use BindTouch in SetupPlayerInputComponent
PlayerInputComponent->BindTouch(IE_Pressed, this, &AMyCharacter::Func1);
PlayerInputComponent->BindTouch(IE_Released, this, &AMyCharacter::Func1);
// Moved
PlayerInputComponent->BindTouch(IE_Repeat, this, &AMyCharacter::Func2);
Hii DanM,
thanks for replay
i have kinda done this way but not know to processed afterward please guide me.
void OnTouchBegain(ETouchIndex::Type TouchType, FVector NewTouchLocation);
void OnTouchEnd(ETouchIndex::Type TouchType, FVector NewTouchLocation);
FVector2D PrevTouchLocation;
bool IsTouching;
-------------------------.cpp
PrevTouchLocation = FVector2D::ZeroVector;
IsTouching = false;
void AMyCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
check(PlayerInputComponent);
PlayerInputComponent->BindTouch(EInputEvent::IE\_Pressed, this, &AMyCharacter::OnTouchBegain);
PlayerInputComponent->BindTouch(EInputEvent::IE\_Released, this, &AMyCharacter::OnTouchEnd);
}
void AMyCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
/\*TouchUpdate();\*/
APlayerController\* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0);
if (PlayerController == nullptr) return;
FVector2D CurrentTouchLocation;
PlayerController->GetInputTouchState(ETouchIndex::Touch1, CurrentTouchLocation.X, CurrentTouchLocation.Y, IsTouching);
if (!IsTouching)
{
SetActorTickEnabled(false);
return;
}
}
void AMyCharacter::OnTouchBegain(ETouchIndex::Type TouchType, FVector NewTouchLocation)
{
APlayerController\* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0);
if (PlayerController == nullptr) return;
PlayerController->GetInputTouchState(ETouchIndex::Touch1, PrevTouchLocation.X, PrevTouchLocation.Y, IsTouching);
SetActorTickEnabled(true);
}
void AMyCharacter::OnTouchEnd(ETouchIndex::Type TouchType, FVector NewTouchLocation)
{
SetActorTickEnabled(false);
}
Well your screenshot should translate to the following (excuse the terrible naming)
void AMyCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
InputComponent->BindTouch(IE_Pressed, this, &AMyCharacter::PressedAndReleased);
InputComponent->BindTouch(IE_Released, this, &AMyCharacter::PressedAndReleased);
InputComponent->BindTouch(IE_Repeat, this, &AMyCharacter::CustomEvent);
}
void AMyCharacter::PressedAndReleased(ETouchIndex::Type, FVector Vec)
{
PrevTouchLocation = FVector2D(Vec.X, Vec.Y);
}
void AMyCharacter::CustomEvent(ETouchIndex::Type, FVector Vec)
{
const FVector2D Loc = FVector2D(Vec.X, Vec.Y);
const FVector2D Delta = (Loc - Location) / 5.0;
AddControllerYawInput(Delta.X);
AddControllerPitchInput(Delta.Y);
PrevTouchLocation= Loc;
}
Love you teach and thank you for teaching me the right way .
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.