Hi all, I am spawning an BP actor in the world in VR. Now I want to attach a new (same) spawned actor to the actor that’s already in the scene.
2 questions:
How can I do this in BP? Now I get the error that the actor can’t be attached to itself?
The actors have physics enabled. When placing the first actor I disable physics and it stays on that position. How can I make it happen, that the second actor attach to the first actor (snap to target) and the 1st actor stays at the same position without moving/rotating?
I will spawn another actor “Attacher”
When you spawn the first “Attached actor” you get a ref and make an event to send this ref to the “Attacher” actor
When you spawn other actor “Attached” you call an event on “Attacher actor” if it’s not eaqual to the first one then attach the Attached to the first attached actor.
Or in attacher get all actor of class attached actor, if Actor is different from the first one then attach to first attached.
Or in the spawner add tag when spawning and work with the “has tag” function.
I understand what you say in text, but as a newbe to unreal it’s a bit difficult to convert in to BP.
I want to give tags a shot, and looked at some info on YT, but it didn’t work that way. In my spawner I have to set a tag for that actor and everytime this BP is called again, it has to set a new tag right?
So in my to attach actor, I have to look if there’s a specific tag?
I set up my scene now that you can spawn endless the same actor and also dlete them, so how can I handle this?
I set an tag array after the spawnactor node, make an array and I guess now I have to set a variable to count the tags? But can it only be input by strings or names?
A blueprint is a “class” (essentially, a “template” that you can instantiate – very much like a blueprint for a house.)
An actor is an “object” (also known as “instance”) – very much like an actual house, built from the blueprint (class.)
“Self” inside a blueprint code execution graph, refers to the object, not the class.
If you want to “spawn a new instance of the same blueprint that created this object” then you can use “Spawn Actor From Class” and pass in “Get Class” of your current blueprint as the class to create a new instance of.
This object will create a new actor instance, that it returns as an object, that’s the object you should attach to the “current” instance of the blueprint that is going to be the parent.
And, if that attachment says “attach actor to self” then the actor you get in the “Get Actor By Class” return value is the same as the actor that ticks.
And, in On Begin Overlap, you’re trying to attach an actor to nothing.
Whatever you’re trying to do, doesn’t make sense to me. I don’t know what to suggest here, because the fundamentals of this blueprint doesn’t tell me what you actually want.
Thanks for the reply! I am quite new to unreal, so my BP aren’t that high quality yet
Waht I try to achieve is the following situation:
Here some screenshots of the level:
This is the level as it is build. Static wall with socket (cube) where I want to attach the panel.
The actions I want: overlap green cube with the white (socket) cube → attach the sheet horizontally to the wall. No rotation in any axis.
Cubes are triggers. Socket is in the centre of the white (wall) cube:
So far so good, the panel attach to the white cube socket.
Sheet has grabcomponent and physics enabled.
Then I spawn with a widget another (same) actor and want to attach this above the already placed actor of the panel.
So when green trigger overlaps blue trigger, it must attach to the first panel (so that the green box snaps to the blue box)
And after that it must be possible to remove the attached actor again or even place 2 or 3 more above it in a row.
Also later on, there will be a slection of more BP-actors of different sizes who can be connect to these actors. You can also “delete” a spawned actor by detroy actor.
But the problem is in the blueprint, you’re not keeping it straight which actor is being attached to which other actor.
Also, you’re asking for Get Actor By Class when there can be more than one actor of that class in the scene, so you’ll get some random actor, which is unlikely to be the one that you really want. You should generally use components and reference them by direct name reference in the same blueprint, rather than doing any kind of dynamic lookup.
And you really don’t want to be attaching every tick.