Hello, I want to know if there is a way for the actor to change automatically in a certain time (second)
there I would like the coin to transform back into the box in x seconds
on the switch
in the box
Hello, I want to know if there is a way for the actor to change automatically in a certain time (second)
there I would like the coin to transform back into the box in x seconds
on the switch
in the box
what you are looking for is just the “Delay
” node (you can get it by just right click empty space and searching for “delay”) which takes in an input of float seconds, and after that timer it will do the thing off the arrow out.
you could also do this with an accumulator in Tick()
if you are already using Tick for something else already. You would have a Float variable that has the DeltaTime added to it, then when it is >=
a given value then you can swap it back.
for blueprints if you are not already doing something else with Tick()
then a Delay will probably be much better for something that shall be on a set amount of time.
Hello, thanks for responding, could you show me graphically because I am somewhat new to this?
this (you can just right click anywhere empty in the event graph, or just pull out of any exec-pin
and search for “delay”)
the thing coming of the Out-Pin
arrow will only be done after the timer has elapsed.
the part about the accumulator should only be done if you are already doing something else with Tick()
as it can be a bit much to use a blueprint Tick()
just for an accumulation timer.
I understand, but what I’m looking for is that when I activate the switch, it instantly changes appearance and after a few seconds it returns to its first state, it would be the other way around.
And in which actor do I place those nodes? And how would he connect with the other actor?
ideally in the actor whose mesh you’re changing. Call the Custom Event when the mesh needs to change. You already communicate with the coin here somehow:
You could use just that. Or, if the coin is a new actor that you spawn, you may need to reverse the process. Destroy the coin, spawn the box again.
no, it doesn’t work
I put this in the actor coin
there where it changes to the box
and I put this on the switch, it created its collision
You static meshes are set to none. But aren’t you destroying those actors? A destroyed actor cannot do anything with Delay - you’d need to handle it all some place else.
Wouldn’t it be simpler to just replace meshes?
Can I give you the project? It’s not working for me.
out of the “completed”-Pin of your ForEach trigger the Dalay
then out of the Delay
“Complete”-Pin do another ForEach that walks through the same collection changing them back.
this accounts for all of the actors that are Destroy
ed through the collection, and utilizes "the same’ timer for all of them.
the thing that is called on each one could be an event as an object Should be responsible for changing its own mesh, and it is reasonable to have some other object tell it the change should be made.
so after taking another look at your images in your initial Post I think this might be an order of operations thing, more then a “how do I do X”
I am going to go from the collision (I will be doing this in sudo-code this is just faster then re-creating your entire system for me)
I apologize for the spelling of your names on the part of language and I didn’t originally spell them)
1-check if OtherActor.StaticType == SuperMarioEnano then 2 otherwise 6
2-forEach ( Block in CajaLadrillo ) do 3
3-if ( Block != nullptr ) call Block->Conversion() 4
4-Spawn a Moneda1 at the same location as `this`
5-destroy `this` "this will remove the item from the collection"
6... "I do not know what is here as it is cut off"
at the start of 6 the collection is (or nearly because of how Destroy can have a slight time delay but will be evident after the Delay()
finishes) empty there is nothing to call a function on the reason it doesn’t crash is because you have the IsValid() check which is “OK” to fail.
I am pretty sure that if you put a PrintString()
coming out off the completed from your Delay
and into the string input the size of the container it should be Zero.
the way to fix this is give the Box some state member variable (integer or enumeration, it could even be a boolean but this falls apart if there is ever to be more then 2 states) then in Conversion()
check the state member variable for the current state if the current state is “block” (whatever that means 1 == “block”) turn off the blocks collision and rendering (**
), then spawn your “coin” at the current location (remember to get the reference to the coin that was created for later)
then when the Delay expires and you call Conversion()
again. if the state member variable is “coin” (this could be like 2 == “coin”) and the coin that was created still exists you can either hide the coin (**
) or destroy it which ever you prefer, and then re-enable the rendering and collision of the box.
if the coin doesn’t exist any more that means it was probably collected by the player so then destroy the “block”
**
take the reference/pointer of the blocks static mesh and call SetHiddenInGame()
with NewHidden = true
then call SetCollisionEnabled()
with NoCollision
great, it worked for me, thanks
depending on how much you want to duplicate Mario P-Switches
instead of considering a “coin” and “block” as 2 distinct items, you could instead think of them as the same item just in different states.
this way they can even share say a box collider (unless you want pixel perfect collision on the sphere/disk)
and they just so happen to have the 2 meshes to swap between. a “Coin” placed in the world is a “Block” that has ObjectState = “Coin” (or whatever you ended up using), and vice-versa.
This does have some negatives and positives though:
Less likely to run into potential memory segmentation by randomly creating a bunch of actors, preventing possible slowdown for creating a bunch of actors all at once (as SpawnActorOfClass is meant to happen on the main thread), and this can further enforce “object self responsibility”, BUT each Coin/Block now has additional weight in terms of data because they might have a mesh sitting around that is rarely used.
as a note where this thread was opened as a question, so be sure to mark the “accepted answer” to your question, or the one that helped you solve your issue (if they are not the same)
Yes, I am venturing out and learning this working method. It is complex and for me I still feel like a beginner but it is great to know and improve my knowledge. I only used Unreal to make renders and videos but when making video games it is another world but it is very good to know and learn it.