We are currently developing a card game with a small team.
We are struggling with how to implement animations for the cards themselves.
We would like to make the cards in the hand look like they are floating in the air.
Currently, we are spawning the number of BPs of each card, and implementing the following on the BPs themselves.
However, this causes the cards to move together as shown below. Also, because the movement is linear, it does not give the feeling of floating.
Should these animations be controlled by AnimBP instead of BP, even if they are on cards?
If you know something about this, I would like to know what the solution is.
They move together since they are spawned at the same time
Adding a random delay before you start the moving should fix it.
You could also fix it by just creating a float-variable (let’s call it moveTimer) that you increment by delta each frame, and use that float to find the current position.
I’d just do sin(moveTimer)(movedistancevector.up)
Then to make them move with different offset, just set the float-variable to a random value on start
You should reset the moveTimer variable each period to prevent floating-point errors
With this solution you also get a nicer floating-effect as it doesn’t suddenly turn direction without slowing down
Consider adding a timeline to each card’s actor. Randomise its playrate and / or add delay to its initial execution.
Since timelines can be loaded with curves, it would give you quite a bit control over the movement; to a point where each card can shift in a unique manner.
The curves can also be loaded dynamically so the animation can differ depending on the card state / type.
A side benefit is that you wouldn’t need to rely on Tick (but it’s OK here anyway).
The TimeLine above has an Alpha track whose value will drive animation using linear interpolation - Lerp. Shift + Click in the graph to add points. Right click them to change interpolation method. The TL lasts 1s and is looping.
Assuming the card actor has a component attached to the root:
The above effect is exaggerated to demo - as subtle as a trojan horse. Also the vector should have been transformed to local, not world - now they just bob about
And you can, ofc, move the entire actor instead. This is just one method of handling it and can be further improved.
You can output a vector and have the entire transform animated iside the timeline, without the need to Lerp anything but it would become more rigid this way. Also Event tracks will fire off at specific time:
Again, what method to choose depends on the scope and desired complexity. This may seem over-engineered compared to @FishBone0 suggestion.