Forum begins after the advertisement:
- This topic has 10 replies, 6 voices, and was last updated 1 year ago by g Dni.
-
::Hello,
I have 2 different characters that look different but your character selector only implements the scriptable object. How can I make the characters also look different with animations etc not just the stats?
::I’m not very clear about the inner workings of the Vampire Survivors series’ codebase, but generally speaking, if you want different animations for another character, you will have to create a different Animator Controller for the other character and prefab it.
Let me know if that makes sense.
::Hi Jeremy Lock, that’s an interesting question.
It sounds to me that you want the sprite and animator controller to be different depending on which character is selected. This is a relatively straightforward process.
- First, you have to add a sprite and animator controller fields to the
CharacterScriptableObject
- Then, when assigning the data in the
PlayerStats
, simply change the sprite and animator controller to that of the characterData
‘s
Hope this helps!
::Hi Xavier Lee
im currently having a problem with the second step of assigning the data to the PlayerStats script, could you send me a picture of the code?
::Hi Windfinz, we post all our codes in the accompanying articles for each video. You can find a list of all the articles here: https://blog.terresquall.com/series/creating-a-rogue-like-vampire-survivors/
::Hi Xavier Lee
I have the same question. I make the prefabs of characters with different sprite and animation. Then i add the GameObject field of characters’ prefab to the characterScriptableObject. But it doesn’t work.
::Hi g Dni, do you have screenshots / videos of the error(s) you are encountering?
::
void Awake()
{
......
currentSprite = characterData.Sprite;
currentAnimatorController = characterData.AnimatorController;
}
void Start()
{
//Done
transform.GetComponent<Animator>().runtimeAnimatorController = currentAnimatorController;
Debug.Log("currentAnimatorController: " + currentAnimatorController);
//not work
transform.GetComponent<SpriteRenderer>().sprite = currentSprite;
Debug.Log("sprite: " + currentSprite);
}
I followed the suggestions. It wokrs for changing animator, but not for sprite.
::What does your Debug.Log("sprite: " + currentSprite);
line print?
::It print the exact sprite which i wanted. I found the problem caused by animator and i fixed it by adding the Idle animation.
Advertisement below: