Interaction with objects

Hello. How to delete one random object on the map, I delete everything at once

Hey @Online_Learner_7MIqi!

This code doesn’t seem to have any errors that would make it grab more than one object. Things that could cause that:

  1. Maybe your collider is too large, and is overlapping all objects.
  2. Your objects are actually static mesh instances, and you are deleting the primary actor.

If you could bring us more information, we will be able to help better!

Hope to hear back soon so we can iron this out!




I want to make sure that objects that appear at a certain moment are removed in a random order. Now they are deleted all at once

Ah, so it was the first option:

Right now, because you are spawning the garbage within the collider, they are all getting deleted.
Try moving those spawn points out of the range of the sphere collider, or making the sphere collider smaller.

You said you wanted random trash earlier, can you elaborate on that? What is it you’re trying to do more specifically, and why? What’s the use case so we can figure out the best way?

I need to make it so that when the sphere is turned on for the actor, one spawned garbage object is removed.

So you can get rid of that sphere if you’re not using it for anything else- a Multi-Sphere trace will work better and faster!

I made a mock-up for you. This should work, or at least get you most of the way there!

Overall:

Hope this helps! Let us know how it goes! :slight_smile:

1 Like

Thank you very much. Everything turned out perfect. Your idea of ​​ray tracing instead of a sphere works as it should. I want to create trees using the same method (tracing). Tell me how to properly make the trees spawn one by one. All of them spawn at once for me.



Sure thing!

If you just slap a delay on there, you can have them appear one by one with a time difference you determine! :slight_smile:

image

I made the spawn of trees using your method. How can I make sure that the spawn does not repeat in one place several times?



Ah, well what I gave you was without all of this other information. It looks like in your “Spawn Tree” you have an array of classes called “Tree”. What is this array? This will spawn every listed class in that array, though as it’s labeled singular I’m assuming you just want ONE of them?

What it seems like you’re trying to do here is spawn one tree per interaction. Would that be the case?

There is only one tree element in this array. . Yes, I want to create one tree for each interaction. But they spawn several times in one place.


555

Okay, first things first, if it’s just one class right now, let’s take out the “ForEach” just for readability. Minimizing nodes is important, if you need to use an array later you can always re-expand it. :slight_smile: We want to remove anything that may contribute to the issue.

Now, let’s talk about what it is you want. First, there will be trash. When there is an interaction, you want to remove one piece of trash at random, yes? And that’s figured out.

You want the trees to spawn in those same locations, on the object “Spawn Tree” right? So you need something to say “Hey, a tree has already been spawned here.”

So open your SpawnTree Blueprint, and add a Boolean called “IsTreeSpawned?” default set to false. After that we just have to work in checking that bool before adding an item to the array, and setting it once the spawner is used.

Hope this gets it solved for you!

1 Like

Thanks a lot. everything works perfectly

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.