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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Why 'Spawn Actor From Class' node returns actor reference when get class from other node?

Look.alt text

To set material of actor, it needs actor's primitive component. No problem is in here. BUT, When I connect Class pin in Set Building to Spawn to Class pin in SpawnActor Node, Return pin doesn't give reference of actor Floor. So return pin and primitive component pin are disconnected. like this. alt text

And I wanna know why.

Product Version: UE 4.19
Tags:
d.png (164.8 kB)
dd.png (156.9 kB)
more ▼

asked Apr 14 '18 at 01:01 PM in Blueprint Scripting

avatar image

KeungKeung
3 1 7

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

3 answers: sort voted first

The reason why this happens is because the types of class references aren't the same. Your BuildingToSpawn might be of type "Actor Class Reference", or something similar, which is a reference to the class higher up in the class hierarchy. Your Floor Class is derived from Actor, but if you get an Actor Class reference, you can only get components from the Actor class.

And the class "Actor" does not have a floor mesh by default, unlike to your own class, "Floor".

Meanwhile if you select Floor class from the drop-down of the spawn actor, you will always assign a "Floor Class Reference".

So, either change the variable type of the class variable to "Floor Class Reference", either by changing the type of the Set variable before the SpawnActor -node, or use the drop-down in SpawnActor instead. If you want to keep on using "Actor Class Reference", you need to cast before you can access the floor mesh.

alt text

spawnactor.png (282.5 kB)
more ▼

answered Apr 15 '18 at 11:29 AM

avatar image

JoSf
253 2 6 9

avatar image KeungKeung Apr 15 '18 at 03:28 PM

You really helps me a lot. Thx. I will try it tommorow. Im wondering to people like U. People like u helps others passionately with no resons. Cool.

avatar image Vaheva Apr 15 '18 at 08:30 PM

It's up to you. If you need for single blueprint and only change floor material, you must use cast to floor blueprint then get floor mesh. My solution is universal, no idea usable or not, just working. Here many ways to achieve desired effect, but it must follow some rules.

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

It wont connect the return pin because the variable class isnt a set value until runtime. Ao the varibke could in theiry be any class and not all classes have the floor component

more ▼

answered Apr 14 '18 at 03:20 PM

avatar image

ThompsonN13
10.1k 33 10 23

avatar image KeungKeung Apr 15 '18 at 10:04 AM

Thanks. but I wanna put spawn actor and set material nodes to function. And get class from event graph. And also I wanna set reference of Floor to variable and set meterial from that variable. how can I do those things?

ps. "Ao the varibke could in theiry..." Is this sentence typo? or abbreviation?

avatar image ThompsonN13 Apr 15 '18 at 02:35 PM

that was a combination of big hands on a small phone and not checking what i wrote closely.

avatar image KeungKeung Apr 15 '18 at 03:21 PM

Lol bootyful.

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

Hi

Fast answer, actor reference is for whole actor, not for actor mesh. You need to get mesh node from referenced actor to set it material. So get node from Floor (ref.) Get Mesh (can have different name, just this is your mesh in floor actor), then set material.

more ▼

answered Apr 14 '18 at 02:17 PM

avatar image

Vaheva
1.3k 24 26 49

avatar image KeungKeung Apr 15 '18 at 10:02 AM

Thanks. but I wanna put spawn actor and set material nodes to function. And get class from event graph. And also I wanna set reference of Floor to variable and set meterial from that variable. how can I do those things?

avatar image Vaheva Apr 15 '18 at 01:48 PM

With function is a little problem, because as I see, you have to do cast to FloorBP after spawn to get floor mesh. I will do little test, now I'm busy.

avatar image Vaheva Apr 15 '18 at 02:35 PM

Ok, I see only dynamic solution works for function, is set mesh and material, because this is correct way. Here Function screen:

alt text

here is function call alt text

and here function inputs: alt text

Actor Floor is empty actor, mesh will be created and material set: alt text

You can use it in any other procedural actor, not only floor ofc. Sample is jus start, not production solution.

avatar image KeungKeung Apr 15 '18 at 03:23 PM

So... am I have to keep mesh in BP that I am fixing? Not floor BP? If it's true, I better make floor as component not other BP. That seems not good

(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