Allowing enemies to be turned into small animals temporarily, making them unable to deal damage to targets.
Here, we refer to the player's code for shapeshifting and replicate it for the NPC code.
Principle:
- Cache the model, animations, and behaviors.
- Instantiate the new model to transform into, set the original model's transform parameters to the new model, and hide the original model.
- Update the UI name and icon.
- Set the animation controller and Avatar.
- Update and reset the NPC's behaviors and animations.
- When the transformation ends, destroy the transformed model, show the original model, and restore the cached animations and behaviors. Update the state to remove the transformation.
Fix Steps:
- Add a new variable in the
RPGEffect.cscode to store the NPC prefab, so it can be synchronized with the settings on the AI unit side.
See image A.
public RPGNpc shapeshiftingNPC;
Then, also write the save data in the CopyEntryData() method below.
See image B.
original.shapeshiftingNPC = copied.shapeshiftingNPC;
- In the
RPGBuilderEditorEffectModule.cscode, within theDrawView()method:
See image C.
Add the newly created variable to get the NPC prefab.
You can search for the location ofcurrentEntry.ranks[i].shapeshiftingAnimatorControllerCombat.
currentEntry.ranks[i].shapeshiftingNPC = (RPGNpc)
RPGBuilderEditorFields.DrawHorizontalObject<RPGNpc>(
"NPC Prefab", "", currentEntry.ranks[i].shapeshiftingNPC);//NEW ADD
This way, there will be an additional option in the editor, allowing you to drag in NPCs from the AI units. We need to obtain the Phase and NPC Prefab from it.
(In RPGBuilder, under Combat -> Effects, create a new Effect with Type set to Shapeshifting. Between the Animator Controller Combat and Avatar in the RANKS, there will be an additional option for NPC Prefab.)
See image D.