Yes, each BP_Road gets a “Block Index” from “Last Block Index” that is being incremented after each BP_Road object is spawned. You should be able to see it in the screenshots.
You are incrementing it after the spawn. The newly spawned road has no notion of the new value after the spawn. (the roads do not share this resource).
It’s a problem of order of operation.
If you are triggering the spawn road function from another actor (probably some form of controller) then I would suggest passing in the increment into the spawn road function and incrementing it in a loop inside of the spawner passing in the information with each iteration.
If you want a self sufficient road that spawns other roads depending on a variable then you need to write a recursive function that will pass it’s current iteration.
Note:
Spawning actors will not work in the editor itself. They will only be visible once you begin play. This is probably not what you are looking for if you are using this in a level (unless it’s a city builder or rts)
Please clarify what type of scenario you are going for with the road spawning.
Also note that you are spawning each actor in world space, and not relevant to each other.
Each new spawn will have it’s Y and Z coordinates at zero.
Though this does not take into account the offset of the first road. You would need to pass it’s position in the spawn road function and spawn the next one relative to the previous. (now it’s fixed coordinates)
That’s the point. I want each object to have a different value.
If you compare the screenshots that i posted in my original post, its the same value i am assigning. But it works when do it on the SpawnActor node, but not afterwards via Set Value on the same node. Its just 2 ways to assign the exactly same value on the exactly same object.
One just works and the other one doesn’t. I was just wondering why. I can live with setting the value directly on SpawnActor, but I was just curious why I cant set it right after spawning. My guess is, its because the object is somehow not ready to have the value changed yet.
If the bluerpint is a spawner and not an instance of road itself, then calling spawn road does increment the internal value of each new instance of the road.
Please post the class of blueprint next time to clarify what you are trying to achieve. We are not mind readers on the forum
You can set the variable of spawned actors either through the expose on spawn function or using the return node after spawn, but you have to follow the logic to make changes to the variable before setting it on the actor or you will pass in the current value that is assigned to that variable.
Hmm the funny thing is, I don’t 100 see where my mistake was, but when I tried to explain my thinking and screenshot the values of the object with breakpoints.. I couldn’t replicate my error XD
Both methods seem to work fine now. o.o
Hah, well thanks for helping me undestand this anyway. <3