x

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"

How to spawn actors from blueprint in C++?

Hello.
I'm trying to make a shooting mechanic in C++ and I have no idea how to spawn an actor from blueprint in my Player Class.

Can you help me?

Product Version: UE 4.14
Tags:
more ▼

asked Jan 29 '17 at 02:43 PM in C++ Programming

avatar image

J0K3R_12QQ
94 21 24 28

avatar image teak421 Jan 29 '17 at 03:44 PM

To add onto what S-ed wrote above, Lauren Ridge has a C++ tutorial on how to make a battery collector game and in it there is a video on spawning volumes. This might help... https://www.youtube.com/watch?v=mSRov77hNR4&list=PLZlv_N0_O1gYup-gvJtMsgJqnEB_dGiM4

avatar image J0K3R_12QQ Jan 29 '17 at 03:54 PM

Thanks for your help

avatar image J0K3R_12QQ Jan 29 '17 at 04:50 PM

Actually, I have a problem.
This tutorial really helped me, but I want to spawn an actor from blueprint and from this I can only understand how to spawn it from a C++ class.
What should I replace to spawn it from blueprint?

avatar image S-ed Jan 29 '17 at 06:25 PM

@teak421 Nice. I didn't know they've updater the tutorial. It one one of the best but code was incompatible with new ue4.

@J0K3R_12QQ Maan. Use search (it's on the top of the page)

https://docs.unrealengine.com/latest/INT/BlueprintAPI/Game/SpawnActorfromClass/

avatar image teak421 Jan 29 '17 at 06:26 PM

Has the SpawnActor stuff changed since that tutorial? @s-ed

avatar image S-ed Jan 29 '17 at 06:36 PM

I don't know. The one @teak421 linked is newer. Old one was like back in 2014. And it didn't work since many changes in source were made.

avatar image teak421 Jan 29 '17 at 06:38 PM

I wonder if Epic should just remove the old tutorials because it just confuses people...??

avatar image S-ed Jan 29 '17 at 07:09 PM

Some people may use old version of engine.

Epic just should add some info or link to newer versions. But they're really busy, there's not much people working on web content.

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

1 answer: sort voted first

You need UClass pointer of blueprint class to use it with SpawnActor,

In C++ you can get UClass pointer of any class via static function StaticClass(). It impossible to get blueprint UClass like that because blueprints don't exist in compile time, you need to get UClass in runtime. You either do that with FClassFinder in constructor (it only works there), here example of it with widget blueprint (you can get path by right clicking asset and using "Copy Refrence"):

https://answers.unrealengine.com/questions/552553/cant-find-widget-blueprint-class.html

or there a lot simpler solution, make UClass* varable or TSubclassOf editable in property editor and then set in there, property editor will show both C++ and Bluepritn classes to choose. For example you make class which spawn something, you can make property which decides what it spawns.

more ▼

answered Jan 29 '17 at 07:44 PM

avatar image

Shadowriver
35.2k 921 166 1098

(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