x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Arrow components - Click event

Hi!

I have to render arrows in the three axis and manage the click events on this arrows to move the actors. I created an actor with some components, in which are included the arrow components (defined in ArrowComponent.h). The problem is that the click events never fire in these components.

Code used to set the event in the BeginPlay function:

 flechaX->OnClicked.AddDynamic(this, &ALuz::onClickFlecha);

And the code of the function:

 void ALuz::onClickFlecha(UPrimitiveComponent* pComponent){
     FString s = "Click";
     GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, s);
 }

I tried with other component in the same way and it worked, but no with the arrow. Maybe a collision mesh problem?

Thank you.

Product Version: UE 4.9
Tags:
more ▼

asked Apr 14 '16 at 08:15 PM in Bug Reports

avatar image

Gastón Giménez
38 8 11 11

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Solved adding a UBoxComponent to manage clicks on the arrows.

Code for one arrow:

In the .h:

  UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components")
  class UBoxComponent* colisionFlechaX;

In the constructor in the .cpp:

  colisionFlechaX = CreateDefaultSubobject<UBoxComponent>(TEXT("colisionFlechaX"));
  colisionFlechaX->SetBoxExtent(FVector(70,10,10));
  colisionFlechaX->AttachTo(modeloLuz);
  colisionFlechaX->RelativeLocation = FVector(35, 0, 0);
  colisionFlechaX->SetSimulatePhysics(false);
  colisionFlechaX->bGenerateOverlapEvents = false;
  colisionFlechaX->SetCollisionProfileName(TEXT("BlockAll"));
 

In the BeginPlay event in the .cpp:

  UWorld* World = GetWorld();
  World->GetFirstPlayerController()->bEnableMouseOverEvents = true;
  modeloLuz->OnBeginCursorOver.AddDynamic(this, &ALuz::onClickModelo);
  colisionFlechaX->OnClicked.AddDynamic(this, &ALuz::onClickFlechaX);

Then now only have to implement the onClickFlechaX function.

more ▼

answered Apr 17 '16 at 06:05 AM

avatar image

Gastón Giménez
38 8 11 11

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Actor and Component click events use collision system, if your actor/component can't collide it can't be clicked, arrow component if im not mistaken is visual only, so use same extra shape component around arrow component like UCapsuleComponent

more ▼

answered Apr 15 '16 at 03:18 AM

avatar image

Shadowriver
35.9k 929 169 1105

avatar image Gastón Giménez Apr 17 '16 at 06:07 AM

Thank you!. I solved it using your advice

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question