Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

How to spawn an Actor in a SPECIFIC location?

I have 3 blueprint classes.

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. alt text alt text

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.alt text

Product Version: UE 4.20
image-010.jpg (28.5 kB)
image-012.jpg (25.9 kB)
image-011.jpg (173.1 kB)
more ▼

asked Jan 21 '19 at 09:12 AM in Blueprint Scripting

avatar image

7 1 1 2

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

use the GetClassDefault node to obtain the default value of those clases to spawn them

more ▼

answered Jan 21 '19 at 09:15 AM

avatar image

1.7k 8 3 8

avatar image Binapple Jan 21 '19 at 11:18 AM

No. It still did not work.

Before connected, the defaultSpawnLocation is usablealt text

But after connected, the variable defaultSpawnLocation is gone.alt text

image-013.jpg (63.8 kB)
image-015.jpg (287.0 kB)
avatar image Evigmae Jan 21 '19 at 12:01 PM

Loving how dismissive you are.

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.

avatar image Binapple Jan 21 '19 at 12:47 PM

(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.

Thank you anyway for answering.

avatar image Evigmae Jan 21 '19 at 01:00 PM

yeah, like i said before, don't be so dismissive, just because you don't know how to do it, doesn't mean it can't be done.

Use a select to pick which transform to use.

alt text

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.

0.png (88.5 kB)
(comments are locked)
10|2000 characters needed characters left


more ▼

answered Jan 21 '19 at 12:14 PM

avatar image

1 1

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question