Hi all…
I don’t understand the object…for example here i have to call the third person for take the variable
http://s7.postimg.org/oe3lkoyqf/Immagine.jpg
But i don’t know what i have to set in object
Here the same thing…
http://s16.postimg.org/5fbgljtq9/Immagine.jpg
Now exi will flame me…(and he have right)
I’m not “flaming” you because you don’t know what object to take. I just told you several times that you need to learn a bit “Objective Programming”, because otherwise you will ask this again and again,
like you do now. It’s totally ok to ask this 2-3 times, but you seem to just ignore my advice on learning the language and keep “programming” where you always find this Casting Object “problem”.
You would save yourself a lot of headache and time if you would look into “Inheritance”, “Casting Classes”, “Parent and Child Classes” and that stuff. If you do this, you would understand what the
Casting node wants from you. I already wrote you a complete example 2 times. It just feels like you don’t want to invest time into learning the actual language.
You need to understand the basics of C++ (or any other objective programming language) even when you use Blueprints!
So to fix your problem:
What is “HUDTimer” for a class? A Widget? You need the reference to it then. You created the widget somewhere and you are able to save the return value of the Create Widget node to a variable.
You can then reuse the variable later.
If you need Widget globally (so you want to be able to access them easily in other blueprints) create them in the GameState or other classes that you can just get (Like “Get GameState”) or in your PlayerController.
Just take a Class that you can get easily and save the created widget in a variable there. Then you can get it easily and you have your object for casting.
(If you save the Widget directly as the HUDTimer and not as UserWidget you don’t need to cast the variable in other blueprints anymore).
ALSO:
“DestroyActor” should be called AT THE END of an execution line, so after you set the variable.
Is this post related to another thread?
Kind of. He asked about “What object do i need for this cast” in a few threads and via PM. It’s all ok if he does, you are all open to ask me things if you don’t know
how it works, but at this state i feel like he’s ignoring my advice and then it starts to get annoying in some sort.
is not a widget…but a fuction in a hud.
So “HUDTimer” is the HUD Class?
Then use “GetPlayerController0” and from it “GetHUD” and use that as the Object.
You need a reference to your HUD Timer to be able to cast to it. A reference can be stored when you spawn an actor, create a widget, which also eliminates the need for a cast. Like Exi mentioned, if the HUD Timer is the HUD Class, you can use the Get HUD function return value as your object. A vague example of what a cast will do is if you have an actor reference to your blueprint, you can use that as your object, and it will give you the blueprint reference, meaning that you can access data specific to that blueprint.
He is not flaming you, and I am with eXi on the fact that you need to study OO programming concepts, blueprints are essentially an OO language, which is why those who have a background in languages like C++ are comfortable right away using blueprints.
my hudTimer is a fuction of my hud class… i have to call it in my hud…then i so like exi said to me…but now the variable"minuti" don’t change…
si i tried to use another method… but give me error but this is th right object…i think…
http://s15.postimg.org/o2nuekzp3/Immagine.jpg
i know that the error said to me that this is arleady a hud but in other example this type of cast works…i tried to do only get player controller, but give me the same error
You really don’t need that “CastToHUD”. It won’t do anything. It’s like converting a .jpg file into a .jpg file
Can you please start debugging your code with “PrintString” nodes? Put a PrintString behind the CastToHUDTimer, right in front of the “SetMinuti” with “Cast Worked”
and one behind the “CastFailed” exec of the CastToHUDTimer with “Cast Failed”. Then you know if the cast is working. If it doesn’t work, you have either not set the
HUD Class in the GameMode as the Default Class or that thing is not a HUD.
You don’t always need to cast. Here is a hypothetical example: Let’s say you have an image reference, but you don’t know the other details about it, you could cast to a PNG image class, if the cast doesn’t fail, then you know that it is a PNG image, now you can access properties that are specific to that image type, such as the Alpha channel. Similarly, if you have an actor, you won’t be able to access it’s variables because you don’t know what class it belongs to, so if you were to cast to a class (for example Ball), and the cast doesn’t fail, you know it is a ball and can now access things specific to the ball (friction, bounce height, etc…). Let’s say you already had a reference to the ball, you wouldn’t need to cast, because you already know what class it belongs to, and can already access properties specific to it. The reason that the cast to HUD is pointless is that the object you are inputting is already a HUD, meaning you can already access things specific to a HUD, meaning the cast does nothing at all.
yes the cast works(thanks for teach me this new method for check the cast:D)
Then destroy my actor but my variable don’t works…What can i ve wronged?
And if ihave to spawn a object for a bullet?
What reference can be with a zombi?
I ve created this
http://s15.postimg.org/qudmtf6jb/Immagine.jpg
Now when i set colpo on on i need to move the zombi in a particle mode…
Now when i try to spawn the cast i can’t do the reference…
can someone help me?
i m studyng the c++ but i can’t understan something with the unreal engine 4…
If i have to cast something to the animation blueprint, why i can set as object the get character movement? Or get player controller.
Then with the promote to value i can use only the object as value for my reference to the cast… so it’ s useless for most the case. The most variable that we need to cast are boolean or numeric…
for example what connection may be with a projectile and the hud?
pS THIS IS NOT A SPAM, BUT SEARCHING HELP AND ADD INFORMATION FOR MY PROBLEM.
Could you try to reword your question better? It is a bit hard to understand.
If i have to cast something to the animation blueprint, why i can’t set as object the “get character movement”? Or the “get player controller”.
Then i can use only the object as value for my reference to the cast… so it’ s useless for most the case. The most variable that we need to cast are boolean or numeric…
for example what connection may be with a projectile and the hud?
If you wanted to cast to your animation blueprint? You can’t use the get character movement or get player controller because those both belong to the character blueprint and PC, not the animation blueprint.
and for the bullet? There is no reference
please help me ç_ç