Hi,
I have to ask about a strange result I get when I try to make a static mesh (a tree in my case) to bend to the direction of a hit it receives.
My approach is to use a timeline for the animation. When the character traces the tree, I calcultate the direction it should bend as follows:
(Location - Trace Start) from the hit, normalize it and then convert it to local space (by using the Inverse Transform Direction).
Then the timeline starts and as it plays a float curve (which starts at 0 goes up to 15 and ends at 0) is multiplied by the x and y of the hit direction vector and the result is passed to the static mesh relative rotation.
The problem is that from some directions the mesh does not bend. Do you have any idea of what’s wrong or any other suggestion how can I do it?
It works for a single bend. But as long as I pass the update in a timeline (to have animation) it doesn’t work.
The problem with your solution (which does not apply to the static mesh but to the instance) may be that I use a dynamic instance spawner for the instances (a third party plugin) which may use the instances differently.
In my initial implementation, when the player hits the tree, the spawner removes the instance and replaces it with an indipendant static mesh component. In that case, I cannot use the update instance node but I have to change the rotation of the mesh itself. I will try your solution with the mesh and return.
I wonder if there is a way to animate the rotation of the instance (bend against the player at a certain angle and then return to initial rotation) without the use of a timeline.
It should not matter whether this is an ISM Instance or a Static Mesh; a transform is a transform.
I wonder if there is a way to animate the rotation of the instance (bend against the player at a certain angle and then return to initial rotation) without the use of a timeline.
Like chopping the tree and it springs back, providing feedback to the player? If you’re replacing instances with static meshes:
extend the SM
put a timer inside
use the timer’s progress to lerp between rotations, I’d have the timer sample a curve so you have a mini timeline with minimum overhead
But this could be driven by the player’s timeline, ofc. If you’re worried about cluttering the player class with too many of those, consider reusing the same TL for many animations - TLs can load curves dynamically. How to approach it depends on the scope, ofc.
Thanks for the insights!
I did the right bending after replacing the instances with static meshes and using your world calculation.
As for the animation part:
I suppose I cannot extend the Static Mesh via blueprints, right (i don’t know C++)?
I also suppose there is no way to use some form of looping inside a function (for example to lerp between the rotators), right?
Fantastic!
Yes I have a latent loop in my mind.
And, for anybody interested there is a fantastic plugin (TweenMaker) which does exactly that!
Animates any actor or scene component from anywhere (even inside functions).
So, I keep your calculations for the end rotation but I use the plugin to animate the static mesh from inside my function.