void AMobileOpenCVCharacter::SetupPlayerInputComponent(class UInputComponent* InputComponent) { // set up gameplay key bindings check(InputComponent); InputComponent->BindAction("Jump", IE_Pressed, this, &ACharacter::Jump); InputComponent->BindAction("Jump", IE_Released, this, &ACharacter::StopJumping); //InputComponent->BindTouch(EInputEvent::IE_Pressed, this, &AMobileOpenCVCharacter::TouchStarted); if( EnableTouchscreenMovement(InputComponent) == false ) { InputComponent->BindAction("Fire", IE_Pressed, this, &AMobileOpenCVCharacter::OnFire); } InputComponent->BindAxis("MoveForward", this, &AMobileOpenCVCharacter::MoveForward); InputComponent->BindAxis("MoveRight", this, &AMobileOpenCVCharacter::MoveRight); // We have 2 versions of the rotation bindings to handle different kinds of devices differently // "turn" handles devices that provide an absolute delta, such as a mouse. // "turnrate" is for devices that we choose to treat as a rate of change, such as an analog joystick InputComponent->BindAxis("Turn", this, &APawn::AddControllerYawInput); InputComponent->BindAxis("TurnRate", this, &AMobileOpenCVCharacter::TurnAtRate); InputComponent->BindAxis("LookUp", this, &APawn::AddControllerPitchInput); InputComponent->BindAxis("LookUpRate", this, &AMobileOpenCVCharacter::LookUpAtRate); }
void AFirstPersonCharacter::BeginPlay() { // Call the base class Super::BeginPlay(); if (GunBlueprint == NULL) { UE_LOG(LogTemp, Warning, TEXT("Gun blueprint missing.")); return; } Gun = GetWorld()->SpawnActor<AGun>(GunBlueprint); Gun->AttachToComponent(Mesh1P, FAttachmentTransformRules(EAttachmentRule::SnapToTarget, true), TEXT("GripPoint")); //Attach gun mesh component to Skeleton, doing it here because the skelton is not yet created in the constructor Gun->AnimInstance = Mesh1P->GetAnimInstance(); if (EnableTouchscreenMovement(InputComponent) == false) { InputComponent->BindAction("Fire", IE_Pressed, Gun, &AGun::OnFire); } }