Animation does not play

I’m trying to rotate a cannon.
I made a very crappy model and animation in Blender just for testing purposes.

It seems to work in blueprint.

But in the game it doesn’t work when I shoot

This is the only code I have (Play Montage)

The event is executed. I can see the message “hello” on the screen.

I’m using the custom mode… but I’ve tried the others too

The weapon is an actor (not a pawn)… I don’t know if that could be the problem.

Any idea?
Thank you so much!!

Could you check if that shoot event of yours is being constantly activated? It might be playing the animation for just a single frame, getting activated again and start playing from the start

1 Like

Yes, it is instantaneous.

So I need to run the function PlayMontage continuously every frame I want the animation to play… That’s a problem…

I don’t know how, but I’ll try… Maybe using the Tick event?
Thank you very much for your help!!

In the Tick event it doesn’t work either.

I don’t know what else I can do

I’m curious about something. Can you get a “Debug Key” node and plug that into “Play Anim Montage” function?

Note: That function is not the same as the “Play Montage” that you’re using

Like this? That function is a member of the character class… My weapon is an actor.

you refresh the montage every tick,so it keeps the begin pose forever.

if my assumption is correct.
you want the machine gun to rotate while it shooting.

The montage doesn’t support looping(at least I didn’t find the feature).
so I recommend to make a anim blueprint for the machine gun.if the gun is firing,change a Boolean.and then the anim BP auto plays the rotating animation.this way it can loop.

1 Like

Oh right, I was testing with my stuff and didn’t think about that :rofl: I wanted to see something but nvm. I’ll think of a way to do that using montages, and yeah I also don’t remember using montages for such a thing for myself maybe it’s not possible as
@baobao4435
says but let’s see

2 Likes

The tick event was just to check if it was necessary to execute on every frame…

My real event is executed in a single tick as you can see in this video.

Ok, I’m going to try using an AnimInstance… But I suspect it will only work if the owner is a pawn.

I’m going to try it anyway.

Thank you very much for your help!!

Captura de pantalla 2024-09-03 100908

Thank You!!

1 Like

I’m still investigating but to progress step by step, can we make sure in your animation blueprint, you plugged in a “default” slot to the out pose?

Note: I didn’t mean the character’s one, the weapon’s one

Hold up it was a child right? You make it work in your character animation blueprint as well? I mean no you don’t do that currently but ok I get it. I was thinking about all the different possibilities so I might think of things that don’t fit your use case as well

Yes, I made two animations. The Idle animation, the cannon doesn’t move… and the turning animation where the cannon does move.

I tried it in both modes (with default animation and without animation).

In fact when I use the default moving animation there is no problem…

only the transition from idle to rotation does not work

If you mean if the weapon is attached to the character… yes, that’s right.

Yes, my character’s AnimIntance works perfectly (But they are two independent actors… the character is one thing and the weapon another… the AnimInstance only deals with the character’s movements)

there could be many methods to achieve the effect(no absolute standard one :grin:). You can share yours.

using an animBP,or even not using any anim BP.just add a poseable mesh and rotate its bone(I often do this when it needs simple animation,bad practice :joy: )

it also support actor,you can use this node instead

Weird idea, but you could try creating a blend space for the model, and have the “speed” set on click of the fire button, or just call a play animation node and set it looping, and run a check for input released to stop the animation

1 Like

I actually didn’t have the need to loop an anim montage yet, I used anim blueprints and sometimes montages for less intricate stuff. I got some interesting ideas that may or may not work for montages in my research for this problem but it seems like what
@Ivan3z
is doing works right now :smiling_face_with_three_hearts:

1 Like

But it’s a good idea!! It can work for simple movements like this (A simple rotation)…

But for something more complex like rotating and also having tentacles that also move, it would no longer work… an animation would be necessary.

I’m going to try this… thanks for this!!

I can try it… but first I have to check if AnimBP works for actors… Thanks for the idea!!

They do :innocent:

And if you’re gonna have a dedicated one for it, of course it would be better to control all those intricate animations using satates but if you wonder, you can also make it work with anim montages in that case. Though it would be less practical

play anim montage requires you to have an animbp for the gun with a “DefaultSlot” in anim graph, or it wont work. rather than anim, i would suggest use timeline in cahracter/gun event graph in this context, it’s easy to implement and give same result.

1 Like

Well, that was my initial idea… but there is no way to make the PlayMotange function work :rofl: