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"

C++ Actor Loses Component References when Duplicated/Alt+Dragged

I have a rather annoying issue. I am following this tutorial series: https://www.youtube.com/watch?v=O47Zw94K-5k and at 3:10 on the video, he copies it. I have this issue where whenever I try to alt+drag that rock or duplicate it, the root component acts normally, but the static mesh cannot be moved, and the static mesh on the duplicated actor spawns at the center of the level. I have noticed as well that the actor loses its references to the root and mesh, so they both display "None". Here is my actor's .h:

 // Fill out your copyright notice in the Description page of Project Settings.
 
 #pragma once
 
 #include "GameFramework/Actor.h"
 #include "Interact_Button.generated.h"
 
 UCLASS()
 class SHOOTERCPP_API AInteract_Button : public AActor
 {
     GENERATED_BODY()
     
 public:    
     // Sets default values for this actor's properties
     AInteract_Button();
 
     // Called when the game starts or when spawned
     virtual void BeginPlay() override;
     
     // Called every frame
     virtual void Tick( float DeltaSeconds ) override;
 
     UPROPERTY(EditAnywhere)
         UShapeComponent* Root;
     
     UPROPERTY(EditAnywhere)
         UStaticMeshComponent* Button;
 
     UPROPERTY(EditAnywhere)
         float SpeedScale;
 
     float RunningTime;
 
 };

And here is my actor's .cpp:

 // Fill out your copyright notice in the Description page of Project Settings.
 
 #include "ShooterCPP.h"
 #include "Interact_Button.h"
 
 
 // Sets default values
 AInteract_Button::AInteract_Button()
 {
      // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
     PrimaryActorTick.bCanEverTick = true;
 
     Root = CreateDefaultSubobject<UBoxComponent>(TEXT("This is the root component for the button."));
 
     RootComponent = Root;
 
     Button = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("This is the button mesh."));
 
     Button->AttachTo(RootComponent);
 
     SpeedScale = 100.0f;
 
 }
 
 // Called when the game starts or when spawned
 void AInteract_Button::BeginPlay()
 {
     Super::BeginPlay();
     
 }
 
 // Called every frame
 void AInteract_Button::Tick( float DeltaTime )
 {
     Super::Tick( DeltaTime );
 
     FVector NextLocation = GetActorLocation();
     float DeltaHeight = (FMath::Sin(RunningTime + DeltaTime) - FMath::Sin(RunningTime));
 
     NextLocation.Y += DeltaHeight * SpeedScale;
     RunningTime += DeltaTime;
     SetActorLocation(NextLocation);
 }
Product Version: UE 4.12
Tags:
more ▼

asked Jun 17 '16 at 08:21 PM in C++ Programming

avatar image

JTrocks55
70 6 11 17

avatar image JTrocks55 Jun 17 '16 at 08:46 PM

Also the little orange circle is not there in the world outliner on the duplicate, but there is an orange circle on the original. I never knew what that orange circle means.

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

0 answers: sort voted first
Be the first one to answer this question
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