I have “Unit” class (child of Character, so it uses Character Movement) and a few other child classes, like Player, NPC, Monster, etc. For example, Player and NPC shares the same Animation Blueprint, and Monster has its own (depending on monster type, biped/quad/spider, etc.) Everything is working ok in Editor window, but when i play it in Standalone mode, Player’s animation is not playing. Even more, if i package the game and play it, Player becomes invisible! (I can still control him, but he’s invisible):
Why there is such a difference between editor, standalone and packaged gameplay?
Also, previously i’ve had problems with character rotation - in Editor it was ok, but in packaged game, all characters were rotated by 90 degrees. (In Components, ‘Mesh’ of Capsule Component was rotated by -90 degrees, to match its direction, so it was somehow resetting after packaging) Now, when i was trying to fix this problem, this NEW problem came up. I really have no clue why this is happening. Any clues?
UPDATE: I’ve just discovered that also after restarting editor, player doesn’t have animation - “Anim Blueprint Generated Class” value in Defaults tab is resetting to ‘None’ after restarting. I’ve tried setting it in Construction Script (Set anim class) and it helps to keep this value after editor restart, but in Standalone game it still doesn’t have animation.
OK, i went 100% problem-killer mode: I’ve created a new project and now i’m recreating everything from scratch, checking at what point this problem will come up.
Problem spotted: It looks like one function in Unit class, “GainEXP” was responsible for this - even if it was not called from ANYWHERE. If this function exists, the problem is here, when i’ve deleted it - the problem is gone.
So i’ve discovered that in this function, the problem-causing node is Spawn Actor From Class. It was spawning my custom blueprint called “InfoText” - it was a TextRender with attached point light, used for showing dealt damage or gained exp. When i spawn something else there, then there’s no problem. “InfoText” blueprint has logic responsible for moving this text up (so it floats up over time) in Event Tick. There is also Event Begin Play, and there is the problem:
This code rotates the TextInfo to face player’s camera. When i delete/disconnect “Get Player Character → Cast to Player” the problem is gone. (Notice that at the moment this function isn’t even called from anywhere, it just exists) I’ve tried replacing it with “Get All Actors Of Class (Player)” and casting from there, but it didn’t helped. Any clues?
(Reminder, the problem occurs only in Standalone and packaged game, which is weird)
I’ve found another problem-causer (however, in this case it’s working in Standalone, but there’s no animation in packaged game)
In my “Weapon” class (child of “Item” class) i have function that unequips current weapon. After unequipping, weapon is added back to player’s inventory. So i have GetPlayerCharacter → Cast to Player → As Player → get Inventory → Inventory.AddItem(thisWeapon) The problem is gone after deleting GetPlayerCharacter → Cast to Player nodes. I don’t know how to access player’s inventory in other way. I also don’t know why these nodes cause this problem (and only in packaged game!)
Update: I’ve changed this to Get All Actors Of Class (Player) and access players’ inventory from ForEach loop, but it also causes the problem. To test it, i’ve put there Get Player Controller → Cast to MyController and… It also causes the problem! Looks like any successful call of Player or MyController object causes this problem!
[[[[[[[[[[[[ Breakthrough in investigation ]]]]]]]]]]]]
UPDATE 2: I’ve deleted this “GetPlayerCharacter → Cast to Player” nodes from Weapon class and i’ve put them into Armor class, to see, if they will cause problems from there as well, and… Yeah! Same problem.
Because it’s not ‘Weapon’ class fault, i went higher in hierarchy, to “Person” class. My “Player” is child of this class. “Person” class has variables like “activeWeapon” (of Weapon type), “activeArmor” (of Armor type), “activeNecklace”, etc… When i delete “activeArmor” variable, the problem goes away! (even if this variable isn’t used anywhere!)
So problem occurs, when, let’s say “Armor” class is referencing “Player” class, and at the same time, parent of “Player” class (“Person”) is referencing Armor class (only because declared variable of this type) !
Do you think that’s because some circular reference? If so, why it’s only occuring after packaging?
After trying different combinations, i’ve finally got it - probably it’s a bug! I’ve tested it on new, empty blueprint project on UE 4.6.1. How to recreate:
Import some skeletal model and at least one animation, create a simple Animation Blueprint that plays this animation.
Create “Person” blueprint from Character parent class. Select previously created animation blueprint in its Defaults tab / Animation.
Create “Player1” class that is child of previously created “Person” class. Select imported skeletal mesh in its Defaults tab / Mesh. Drag him into level.
Create “TEST” blueprint from Actor parent class. Make “Test1” function inside it and put [Get Player Character] → [Cast To “Player1”] nodes there, connected to the function input. … OR CREATE REFERENCE TO ANY OTHER BLUEPRINT THAT HAS VARIABLE OF “PLAYER1” TYPE, FOR EXAMPLE CUSTOM PLAYER CONTROLLER WITH “MYPLAYER” VARIABLE OF “PLAYER1” TYPE.
In “Person” blueprint, create variable “testVar” of “TEST” type.
That’s it. Result: Animation is working in Editor window and Standalone mode, but not in packaged game. Both Shipping and Development configurations tested.
It would be nice if someone could recreate this and make sure if this is a bug - or if maybe my UE needs to be reinstalled/my skeletal model (or animation) is somehow broken.
I’ve tested it also on 4.5.1 and the result is the same. To be sure that this problem is not caused by my skeletal mesh/animation, i’ve created a new, simple skeletal mesh (cylinder) with animation. Tested with these, and the problem is still here - so now i’m even more convinced that this is a crucial bug.
I’ve created a simple project demonstrating this bug, in 4.6.1: Project Folder
Now i need to find a workaround somehow… I hope i will not have to wait until it will be fixed. Any clues?
Because the title is not accurate anymore (lots of changes due to my investigation) and this topic became too overwhelming, i’ve created a new, clean question / bug report with the “final” discovered bug and a repro project. Here: BUG REPORT