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"

SpawnActor not visible on camera/game simulation

So the issue i'm having is that, either spawning an actor through blueprint or c++, is not appearing visible through the players camera nor if i play as standalone game. However it appears in editor viewport.

As i thought it might have to do with my project and a deeper problem that i was not able to see, i tried to replicate the problem yet again on a clean project, and the problem persists.

Here is how i replicate it for c++:

MyActor.h

 #pragma once
 #include "CoreMinimal.h"
 #include "GameFramework/Actor.h"
 #include "MyActor.generated.h"
 
 UCLASS()
 class CPPTESTING_API AMyActor : public AActor
 {
     GENERATED_BODY()
     
 public:    
     // Sets default values for this actor's properties
     AMyActor();
 
     UFUNCTION(BlueprintCallable, Category = "Something")
         bool TestingSpawn();
 
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Something")
         AActor * TestActor;
 };

MyActor.cpp

 #include "MyActor.h"
 #include "Engine/World.h"
 
 // Sets default values
 AMyActor::AMyActor()
 {
      // 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;
 
 }
 
 bool AMyActor::TestingSpawn()
 {
     UWorld * World = GetWorld();
 
     if (!World) return false;
 
     FActorSpawnParameters SpawnParams;
     SpawnParams.Owner = this;
     SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
 
     AActor * SpawnedObj = World->SpawnActor<AActor>(TestActor->GetClass(), FVector(0, 0, 0), FRotator(0, 0, 0), SpawnParams);
 
     return true;
 }

Then I need to set an actor to my TestActor. I decided to set it through the editor like so:

1)Place a BP version of MyActor on level

2)Create a BP of an actor with a static mesh component (can be anything, i chose the default engine Cube) and make sure it's movable. Let's call this SomethingActor.

3) Place SomethingActor in the same level as MyActorBP.

4) Now you can add SomethingActor to the TestActor in MyActorBP.

alt text

For the blueprint case, just create two actors, one being the one that spawns and the one that is the class you want to spawn. Happens the same.

You might notice that i also have a custom GameModeBase and a Pawn, that was to make it easier to check the camera freely through my pawn.

I have been trying to solve this all day and i just don't know if it's me that i'm missing a step somewhere or is it rly a rendering bug.

Thank you for your time,

KittyT

Product Version: UE 4.20
Tags:
testcpp.png (1.5 MB)
more ▼

asked Dec 07 '18 at 08:38 PM in Rendering

avatar image

KittyT
20 3 5 7

avatar image KittyT Dec 10 '18 at 05:22 PM

I apologize, i forgot to post what i was visualizing

On this image below, the contour in red means the spawned object, and where it should be on the camera of my pawn, which the camera is the one contoured in yellow

alt text

testcpp2.png (1.1 MB)
avatar image KittyT Dec 10 '18 at 05:48 PM

Adding a screenshot of when i spawn the objects, be it blueprint or c++, i call it at begin play. The one i have active atm is the blueprint call with the spawnactor node found in blueprints

alt text

testcpp3.png (281.7 kB)
avatar image KittyT Dec 10 '18 at 06:23 PM

Just tested this on 4.21, have the same issue... I am just now trying to spawn something from the content with spawnactor, all in blueprints, and i get the same issue. Am I missing something? ;-; It's not the first time i spawned something this way, it is the first time it is not spawning in camera but spawning in the editor viewport though. ;-;

avatar image KittyT Dec 10 '18 at 06:50 PM

Okay, so i decided to also try with later versions, and on 4.19 has no issue. Works just fine. So i tried to see what might be wrong.... I noticed that the pawn i am creating i did not do for the 4.19 test. So my issue is with the pawn itself. I shall try to see why with a default pawn works, but the one i had did not, If anyone has a suggestion is more than welcome ;-;

(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