Download

Cast to anim blueprint from charBP?

for what I want to do, I can’t rely on the tick interval of the animbp to grab variables from the charbp. I need them set instantly. So I’m casting to the AnimBP from the charbp just fine and all works perfect. Except when I try to use this in MP.

All other MP functions work. Here’s a simple test that isn’t working. However if I simply set the VAR with the server function and have the tick event in the animBP set the bool there it replicates the anim function fine.

So I know that casting to the AnimBP is whats breaking the replication. The animBP casting to the charBP works fine. Any thoughts on how to make this work? thx—

castAnimBP.png

Are you trying to get animations played to all clients?

yeah.

It works if I just set the bool to true with a server function in the char blueprint so long as the animBP is casting to the charBP to get the bool value. The issue with this is I have a lot of under a second timers and since the animbp only gets the values every tick, if the player spams the attack button it messes up the timer and the animations get mixed up cuz it’s resetting things before the tick or too late etc, but if you calmly press the attacks it works fine… multiplayer as well.

So instead after each attack I cast TO the animBP set the vars directly and run the server functions there that play the anims. Then default the vars after the attack by casting to it again and defaulting them. Works PERFECT in SP… but in MP, the anims wont play and I’m not sure why.

Its confusing me, cuz it works if i just let the animBP cast to the charbp every tick to get the values but when i do it the opposite way…it dont work in mp.

Just did some testing and was able to get animations working fine with casting to the animBP…

Can you show me the part where you’re casting?

**EDIT: **Forgot you had the screenshot in your opening post :rolleyes:

I think your problem is that you’re casting to the animBP through the server. What this means is only the server is getting the boolean. Try doing a multicast afterwards so all the clients can get the boolean too.

I donno… are you sure you tried that in multiplayer?

I’m having a terrible time with this. seems like a ridiculous issue but… I donno what the heck is wrong.
Like I can get to the point where the character moves the root motion amount its supposed to but the animation isn’t happening. So everything is going thru. the animgraph is true for the montaage slot. plays in SP just fine. but in MP the client moves since it root motion but the animation just dont play. i think ive tried every variation of server to non server setting and playing in both the charbp and the animbp. its probably something small.

Edit: got it to work using multicast after a server event like you suggested in the test. but in the real functions which are massive, its not working right. I’ll have to trial and error it I guess. start multicasting some events here and there and see whats up. Frustrating because I’ve been testing this all the way thru on MP and its been fine. I decided to change how I set vars in the animBP and now its a nightmare in MP. :confused:

thx for suggestions up to now.

Replication was a nightmare for me at first as well … I already thought I got it testing with only one server and one client and after starting a 2nd client I saw that it was still not getting to everywhere. Multicast event after a server event should do for non-predicted stuff. Only problem with that is that it’s usually not done instant everywhere which is good if it’s gameplay relevant but anoying if it’s really just cosmetic and should give the client the feeling it’s done just now (when he presses a key). So sometimes I split this replication up a bit more for unimportant animations that should fire everywhere as fast as possible (even if it’s async) - e.g. start anim on client instant (which is future gametime as the server does not have a clue of this right now), tell the server that he should do it as well asap (which is the only game time that is valid) and replicate via multicast to all clients (which would do it in the past finally) excluding the execution on the client that caused it (so he would not do it twice). I’m even using the OnRep_ functions a lot (instead of server-event → multicast-event) if I need the variable in the characters BP anyway (e.g. some IsCrouchingEnabled as RepNotify) and call some blue print interface functions for the anim BP inside the OnRep_ functions of the characters BP. I’m using blue print interfaces to avoid to set variables via casting or polling between character BP and it’s anim BP.

well i thought I had replication all figured out. I’ve worked with much larger implementations recently playing with blueprints and it all worked no problem. The difference then was that I wasn’t casting to the animbp at all and tick event in the animbp was sufficient. i never thought changing how I set the vars in the animBP would matter so much in terms of replication. because I have X amount of characters and when primary atk is pressed depending on the character different things happen completely, including length of animation, size of sphere traces, delay of unsetting the variables, how many traces are run, if a trace is run etc. I wanted to make it so basically the same functions work no matter what character you are, so future changes dont need to be done in multiple code branches.

This was working fine. The issue though is that there are tons of functions after the top layer setting variables in each step of the way add to that timers that unset things when needed, since the animation length or movement disables vary depending on the action. Because this was all working before I didnt think twice about it. Now I’m like “you get a multicast… you get a multi cast… you get a multi cast…”

of course its not working though. I’d consider these animations important, since its the feedback the user gets that the atk is happening. When the atk doesnt play, the attacked character still takes damage and the rest works. (except the getting hit animations of course, same problem now.)

I don’t know how to use interfaces well. Might be helpful.

Example how to BPI between character BP and anim BP https://www.youtube.com/watch?v=SgsYsViIRYE (minute 3:45) without MP stuff (which could be done via OnRep_ or server-event multicast-event).

Yep. Everything I do is multiplayer. I have Crouch/Fire/AimOffset/etc and it all works for all client, with the caveat you gave of casting to the animBP rather than the other way around.

Took me ages to fundamentally understand how client/server communication works (and I still have issues). Just remember that if you want everyone to see something, they all have to have the data…

finally got it to work. Changed all the Anim relevant variables to repnotify and the only function in each of them is to cast to the animbp and set its corresponding variable there. Got rid of the last function that dos the one cast and sets everything in the animbp at once. The other functions are mostly server set with one multicast. thats a day kinda wasted originally, but at least i learned a few things. Ah well. thx a lot for the info guys.