[Solved]Sprite doesn't show up after moving it

My actor is a BoxComponent with the sprite attached to it. I move the actor 5000 cm far away from its position when it is outside screen(i check this with the frustum of the camera) and i put it in the pool for using it later when i need another actor of this class instead of spawning a new one. I use the same value when spawning a new one or moving one from the pool but when in the last case it doesn’t show up. Once i used a mesh instead of a sprite and it worked so i don’t know why now it doesn’t.

Hey KingDragonX-

To clarify, are you moving the same sprite (that you moved 5000cm the first time) back into position or are you spawning a new copy of that sprite? Can you confirm that the sprite is in the proper location after moving away and confirm that the sprite leaves that position if you try moving it back. Can you post the code that moves the sprite away as well as the code that moves it back / spawns a new one? It may also be helpful to see the problem first hand. If possible, would you be able to send a copy of the project with the issue? If you’re able to upload the project to Google Drive or Dropbox you can send the download link to me as a PM on the forums for privacy.

Cheers

This is when i spawn a new actor:

AProjectile* NewProjectile = UStaticLibrary::SpawnBP<AProjectile>(World, ProjectileClass, Location + FVector(5000), Rotation);
NewProjectile->Pool(OwnerClass, Direction, Damage, Rate, bIsCharacterOwning);
NewProjectile->SetActorLocationAndRotation(Location, Rotation);

This is when i move it far from the screen:

FVector ProjectileLocation = ProjectileToDeactivate->BoxComp->GetComponentLocation();
ProjectileLocation.Z += 5000;
ProjectileLocation.Y += 5000;
ProjectileToDeactivate->SetActorLocation(ProjectileLocation);

And this is when i move back to the player:

PoolProjectile->SetActorLocationAndRotation(Location, Rotation);

Location and Rotation are the same when i spawn them and when i move them back to the screen cause the code is both is the same function.

I’m trying to recreate this is the twin stick template to see if there is other settings interfering with this.

EDIT: At the start i spawn some new actor, then i start to move them back to the screen and here it is the problem. The new actor show themself but when i move them back i can’t see them. In the level i have no Light and a PrecomputedLighting Volume for the size of the screen though.

Cheers

I’ve tried to reproduce the issue however the sprite has been visible after returning to position for me. Here are the steps I used to setup my project.

  1. New 2D Side Scroller project
  2. Add code based on PaperSpriteActor
  3. In the BeginPlay function I get the location and rotation for the actor (saved for later)
  4. I have a “MoveAway” function that contains the four lines of code in the second block you provided
  5. I have a “BringBack” function with the last line of code you posted, using the location and rotation obtained in BeginPlay

When I call MoveAway/BringBack I see the sprite vanish from position and then reappear. Can you confirm if these are the same steps that you’re using? If not can you let me know how you setup your sprite? Also, can you test these steps to see if you get the same behavior I described.

Yes, this are the same steps, i am trying to get this to a new project and see if it works, thank you.

This is the problem in my project, i haven’t tried to create a new one yet. I added a new mesh in the actor and i made a video of my bug.
Sorry for the bad quality

After watching the video it looks as though the projectiles are spawning and moving along until they go off the top of the screen. Are you trying to move the projectiles after they’ve left the screen? What’s happening with the boxes when they reach the bottom of the screen and disappear, are they being destroyed? Can you explain why you are trying to get the projectiles to move back to their starting position, there may be another method for accomplishing the same task.

I added the cube to debug. Anyway it was an optimization cause spawning an actor is slower than moving one back. I’m developing this game for mobile so i really wanted this but i will remove it and go without this, spawning a new actor everytime i need works. Thank you :slight_smile:

Cheers