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"

Cast to C++ actor in blueprint actor

  • cannot do English well...*

I made and spawned an actor class in C++. How can I cast to spawned actor in blueprint?

Exactly, I want to remove the spawned actor in c++ when the spawned actor in c++ overlap the blueprint actor.

Product Version: Not Selected
Tags:
more ▼

asked Aug 17 '17 at 01:50 PM in Blueprint Scripting

avatar image

hansw1126
1 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

You don't need to cast to do so, Destroy() is in AActor class and overlap events return actor that hits as AActor* so no need for casting just call a function on it.

As for casting, you can't cast to Blueprint in C++ as those classes don't physically exist in C++ code, compiler won't know what you referencing to. As for C++ classes in blueprint, they are visible as normal blueprint class.

In your case if you try to execute some code on destruction in blueprint, best way to do so would be place it in OnDestroyed event in blueprint, which will be executed when you destroy actor in C++. Don't need to toy with calling blueprint functions in C++ which would only make code look messy.

more ▼

answered Aug 17 '17 at 07:43 PM

avatar image

Shadowriver
37.3k 936 172 1116

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Hi there. One thing you can do from your blueprint actor is click the component you want to use to check the overlap and set click the plus symbol next to On Begin Overlap from Events in the details panel. (Pictured below)

alt text

Now you should be able to cast to your c++ class from the editor by right clicking and typing "cast to (your class name here)". From there you can execute whatever you want, assuming the cast is successful. If your c++ class has functions exposed to blueprint, you can even call them by dragging off the "As Your Class Name" pin.

alt text

Hope that helps!

more ▼

answered Aug 17 '17 at 07:55 PM

avatar image

Drkephrim
31 2 5

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
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