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++ generated components spawn in world space?

I'm having a very weird bug that I've battled with for a few days now. I'm trying to create a system where players can enter and exit vehicles, so my vehicle class has a BoxComponent that is used for overlap events to know when the player is close enough to enter the vehicle. Here is my code:

 AWheeledVehicleBase::AWheeledVehicleBase()
 {
     DriverSeatTrigger = CreateDefaultSubobject<UBoxComponent>("DriverSeatTrigger");
     HealthComp = CreateDefaultSubobject<UHealthComponent>("HealthComponent");
 }
 
 void AWheeledVehicleBase::BeginPlay()
 {
     Super::BeginPlay();
 
     if (!DriverSeatTrigger)
     {
         UE_LOG(LogTemp, Error, TEXT("No DriverSeatTrigger assigned on %s!"), *(GetName()));
         return;
     }
 
     DriverSeatTrigger->SetupAttachment(RootComponent);
 }

I then have a blueprint class that inherits from AWheeledVehicleBase, where I adjust the location of the BoxComponent "DriverSeatTrigger" to be near the driver's door. The issue I am having is that when I drag an instance of the vehicle into the scene, the BoxComponent spawns at the origin of the world instead of where it is in the blueprint. The weird thing is that I can "reset" the location of the BoxComponent on the vehicle instance in the world and it will snap to where it's supposed to be. Here's a picture of what's happening:

alt text

You can see the BoxComponent located at (1.) at the origin of the world and when I click the reset button at (2.) the BoxComponent snaps to where it should be relative to the vehicle near the driver's door as shown in the blueprint. Any ideas of what's going on here would be greatly appreciated!

Thank you!

Product Version: UE 4.21
Tags:
bug.png (1.1 MB)
more ▼

asked Apr 03 '19 at 03:02 AM in C++ Programming

avatar image

NonPolynomialTim
11 2 4

(comments are locked)
10|2000 characters needed characters left

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