The first one is the Third Person Character blueprint I got from the engine.
The second is BP_Cube created from the cube static mesh.
The third is BP_Shpere created from the sphere static mesh.
BP_Cube and BP_Sphere both have a variable called defaultSpawnLocation of the type of Transform. The default value of them can be seen in the attached pictures.
I want to press F key in game and spawn BP_Cube and BP_Sphere according to their variable defaultSpawnLocation.
This is my implementation. It was not complete because I did not know how to access the variable defaultSpawnLocation in the Third Person Character blueprint.
In any case, you don’t need to connect anything to the Class pin on the GetClassDefaults node. It’s a static class, not a reference to anything. If you connect anything to it you’ll lose its specificity and get the defaults from UObject instead, which is not what you want.
Just as when you SpawnActorFromClass, just pick the class you want and the node will magically transform itself to match that class.
If the value is indeed set as a default, you’ll be able to use it.
(You are really experienced. I did not know how to correctly use the GetClassDefaults node before you told me.)
Maybe I should change another way of implementation to spawn the actor. Because what I want is that the first time I press F, a cube will be spawned at (0, 0, 100) ---- (0, 0, 100) is a location stored in defaultSpawnLocationCube. The second time I press F, a sphere will be spawned at (0, 0, 300) ---- (0, 0, 300) is another location stored in defaultSpawnLocationSphere.
Note that defaultSpawnLocationCube and defaultSpawnLocationSphere are different variables stored in different classes.
So I cannot “Just as when you SpawnActorFromClass, just pick the class” as you said.
The select node allows you to use integers, floats, or enums to pick a value from.
using the bool from a FlipFlop would be a really basic example. But you could use any other number of methods to provide a “state value” to the select node.