x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Replicating animations, aim offset, and SetRelativeLocation

I know these kinds of questions might have been answered already, but I also have another problem that I haven't heard anything about. I'm doing everything on Blueprints, by the way. I'm doing my function replication somewhat by the book, when the crouch key is pressed, I trigger an event running on the server that executes the rest of the crouch logic (in the image), and a boolean is set. That boolean sets another boolean in the animation blueprint, which triggers the crouching animation. Now, the case is, when I go try out the animation in the editor (I set the player count to 2, with a dedicated server) the animation plays in the owning client, but it also plays in the other player character. And, in the other client, the animation does not play at all, on any mesh. Pic related, my crouching code.

The same thing's happening with the aim offset. The animation plays on both of the meshes in the client that looks up and down, but on the other client, nothing plays on both meshes. I need a method to separate animations per player, I thought the player index input in the Get Player Character function might do it, but it turns out it's for local multiplayer. I'm not too sure how to do this.

Then, I also have another weird problem with the SetRelativeLocation function. I use his function due to the fact that when the capsule half height is set, the player character dipped below the ground level, so I set the location when the player triggers the crouch event. All works fine and dandy on the server's side, but when crouching once, the movement is really shaky, and when uncrouching, and the player runs/walks backwards, the mesh gets its location set to the crouch location, and it switches to the standing one, intermittently. When moving forwards, sometimes it's fine, sometimes it does that. I'm especially clueless about this one.

alt text

Product Version: UE 4.8
Tags:
replication 3.png (305.2 kB)
more ▼

asked Aug 02 '15 at 11:21 AM in Blueprint Scripting

avatar image

Shiny Rice
16 2 3 7

avatar image Shiny Rice Aug 10 '15 at 04:48 PM

I've solved the trouble I had with the set relative location function, turns out you have to have two events, one that runs on server and the other that is a multicast, hooked up to the same logic. Furthermore, there has to be boolean variables that describe whether the character is crouched, standing or prone, and these variables must be set to RepNotify. In the functions, you should set the capsule height and relative location of the character mesh. But, I still have to solve the animation trouble. It must be something that is doable in C++ but not in Blueprints, because the default Speed and Is in Air variables do apply to the executing client, but custom ones don't.

avatar image Shiny Rice Aug 16 '15 at 11:53 AM

I've also tackled the animation replication stuff, finally. To control the variables that you have in the animation blueprint, you must have the same variables in your player script, which must be replicated. Then, set the variables in the animation blueprint at the same time you set the ones in the player one. First, you have to cast to your player script, and in the object input, you must place the output of the "Try Get Pawn Owner" function. But the aim offset trouble isn't fixed yet.

avatar image Shiny Rice Aug 16 '15 at 12:35 PM

Disregard the last line of my previous comment, aim offset finally replicates correctly. What should be done, is to use the logic provided in the official documentation, but instead of using the "Get Control Rotation" and "Get Actor Rotation" functions as the target of the Rinterp, you must use the Get Base Aim Rotation function. I'll set this question as solved, now. Hope it helps anyone else.

avatar image TheSecondSense Jun 24 '16 at 11:46 PM

Hi!

I know this is an old question (and you've marked it as solved) however I am wondering if you still have the animation replication blueprint. I am trying to replicate crouching on the server but cannot get it to work. I have tried many ways including (I think) the way you state above. Would you be able to share some screenshots of a working replicated crouch (or similar) blueprint? I would really appreciate it!

Thanks :)

avatar image Shiny Rice Jul 09 '16 at 12:00 PM

I've been working quite a lot on this game of mine. I still do have the animation blueprint, in fact, I've expanded quite a bit on what I had before.

Here's the logic on the player character.

alt text

And here's that crouching logic. Basically, you need to set a boolean variable (Crouching) that replicates with RepNotify. You have to set it both in the owning client and in the server. Apart from this, you have to run the set relative location and set half height function in the owning client and the server as well. In the rep notify function, you have to do the same thing, that is, setting the relative location and the capsule half height again. In the animation blueprint, you just have to cast to the player character script and get the Crouching variable.

alt text

crouching 1.png (210.2 kB)
crouching 2.png (94.2 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Apparently I need an answer to this question to mark it as solved, not comments. Whatever, you can just read them above.

more ▼

answered Aug 16 '15 at 12:39 PM

avatar image

Shiny Rice
16 2 3 7

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question