razkoller
(Raz Koller)
March 27, 2023, 11:39am
1
Hello again Unreal community!
I have this simple door mesh which I converted to a blueprint so I can add a rotation animation to it, so I can toggle opening/closing it.
I want to control that action from another blueprint.
When doing it with a simple âget class of actorâ and promoting it to a variable, everything works just fine.
But Iâve been told that âget class of actorâ is an expensive process and I should use casting instead.
But casting doesnât work!
I followed the instructions. Looking at the door blueprint I can see that it the parent is a static mesh actor, so I plug into the âobjectâ a variable which is a static mesh actor, but casting always fails.
What am I doing wrong?
And is using âget class of actorâ really that bad?
Appreciate the input and insights of experienced devs!
Thank you!
Get actor of class is not too bad if you donât do it on tick, for example.
But I suspect your problem is that you havenât set the âactor variableâ variable?..
Where are you trying to talk to the door from?
razkoller
(Raz Koller)
March 27, 2023, 2:43pm
3
Hi @ClockworkOcean , thanks for your reply!
Iâm talking to the door from a different blueprint that I created just to hold simple actions like âtoggle doorâ.
In it I have these bunch of variables. Including this one, which I set as a static Mesh Actor, which is the doorâs parent class.
So then I try to casting to the door and I put that variable into the object (this is following a tutorial I saw on YouTube).
But casting fails every time.
Is the variable not set? Do I need to actually drag it in and choose âset variableâ?
and if so, what do I put in the blue input?
I am tempted to just use âGet actor of classâ, which just works with no problem every time, but I do want to crack proper casting as wellâŚ
Casting is for when you have a reference ( variable ), and you donât know itâs type yet.
Here, all you need is a variable of the correct type , âSM door blueprintâ.
Static mesh actor, is not the blueprintâs class, BTW, itâs probably âactorâ
All you have to do, is put your âotherâ blueprint in the map, and set the door variable, having made it âinstance editableâ
( the eye, is what you need, then you can set it in the details of the other blueprint in the level / map ).
1 Like
razkoller
(Raz Koller)
March 27, 2023, 4:35pm
5
@ClockworkOcean
OH!
I completely over complicated that one, havenât I?
Yes, that works perfectly. And I donât need to cast or get class or anything.
Thank you so much for your input! It was very helpful!
1 Like