I have an actor that is a torus constructed in the construction script. I have several variables including the torus radius, that I can make public and when I tweak them, I see the resulting torus change, in the actor viewport and in the level. However, when I try to change this radius variable in the blueprint I see no change at runtime. Here is how I am animating the variable:
The print string outputs exactly what I’m expecting but the torus itself isn’t changing. I’ve tried doing the same by animating the timeline from 0 - 1 and outputting that to a lerp node which didn’t work, I’ve tried plugging the output of the timeline into an add actor location node which did work. So the timeline and the output from there definitely seems ok, there is just something preventing my torus variable from changing at runtime. Any ideas?
You need to update the torus after changing the radius in the timeline (basically call what you had in the constructor to generate / update the torus). Just changing the radius is not enough.
Perhaps not all of the constructor needs to be called,but without seeing it it’s hard to guess.
This is what I’m using to construct the torus:
I’m not too sure what I would need to add to the event graph to update the torus
Move the whole code into a function and pass in a procedural mesh component instead of constantly recreating it. Just make sure you clear it before you rerun the function…
Call the function in the constructor and it should update fine. Also rerun it in the timeline update function to get it to animate.
I had a go but no luck. This is the function:
This is the construction script:
This is the event graph:
Did I miss something?
You forgot to add “Generate Torus” in the timeline update (somewhere after set for Torus Rad)
Good news and bad news. The variable does seem to now update the torus shape. But it absolutely tanked the framerate. The bigger the torus gets the slower each frame takes until it gets destroyed. The torus also seems to no longer look like a torus, it becomes like a star with however many points my torus has segments
Well you are recreating the shape on every update. If you only want to change the radius then perhaps you could do that using the normal direction of the polygons and adding an offset to them. This might even be doable on a material basis.
You can also try using update mesh section in place of create mesh section. This might need to allocate less resources to compute it.