TArray replication, RepNotify bug
Very strange behaviour of RepNotify and TArray.
I have this array:
And in RepNotify function
1)Initialize array on server and client like this
2)Now generate new value one by one (when mouse click for example) on the server and print arrays in RepNotify
// Change first item
7 0 0 0 0 <- arr(replicated as expected)
0 0 0 0 0 <- prevArr (okey, all previous values was 0)
// Change second item
7 3 0 0 0 <- arr(replicated as expected)
0 0 0 0 0 <- prevArr (why first item not 7??)
// Change third item
7 3 5 0 0 <- arr(replicated as expected)
0 0 0 0 0 <- prevArr (should be 7 3 0 0 0)
// Change first item again
1 3 5 0 0 <- arr(replicated as expected)
7 0 0 0 0 <- prevArr (now first item is correct, but others still 0)
Is it expected behaviour of RepNotify or bug?
So I've set this up in a slightly different way and got it working.
I'll provide you with my code files so you can take a closer look and get a better idea of how to set it up, but at this time I do not believe that this is a bug.
Basically, TestActor contains the necessary functionality for creating and replicating the array, and then SCharacter spawns test actor and then uses an input to call a server function that generates a new array. TestActor prints both the old and current array, and they matched up as expected.
Have a great day!
answered Nov 15 '16 at 09:37 PM
Sean L ♦♦ STAFF
Follow this question
Once you sign in you will be able to subscribe for any updates here