Forum begins after the advertisement:


[Part 8] My orbShards cannot works

Home Forums Video Game Tutorial Series Creating a Metroidvania in Unity [Part 8] My orbShards cannot works

Viewing 8 posts - 16 through 23 (of 23 total)
  • Author
    Posts
  • #13902
    Elvin Sim
    Participant
    #13906
    Joseph Tang
    Moderator
    Helpful?
    Up
    0
    ::

    Took me a bit, but i found the issue,
    Simply set your Mana Orbs parent object to Active. Orbs 1-3 can be kept inactive:

    View post on imgur.com

    This should work.

    #13908
    Elvin Sim
    Participant
    Helpful?
    Up
    0
    ::

    Thank you very much, it works now!!!

    #13909
    Elvin Sim
    Participant
    Helpful?
    Up
    0
    ::

    and now there have another question, my heartShards can works in the game but when I save the game and out of the game and in again, the heartShards doesn’t update

    #13910
    Elvin Sim
    Participant
    #13911
    Elvin Sim
    Participant
    #13912
    Joseph Tang
    Moderator
    Helpful?
    Up
    0
    ::

    Ah, this is due an intentional error. We did not include code for checking the player’s max health when creating the series, thus, on every reload, it will default to the set max health of [5] in the inspector.
    To solve this issue, simply go to your SaveData.cs:

        //player stuff
        public int playerMaxHealth;
    
        public void SavePlayerData()
        {
            using (BinaryWriter writer = new BinaryWriter(File.OpenWrite(Application.persistentDataPath + "/save.player.data")))
            {
                playerMaxHealth = PlayerController.Instance.maxHealth;
                writer.Write(playerMaxHealth);
            }
        }
    
        public void LoadPlayerData()
        {
            if (File.Exists(Application.persistentDataPath + "/save.player.data"))
            {
                using (BinaryReader reader = new BinaryReader(File.OpenRead(Application.persistentDataPath + "/save.player.data")))
                {
                    playerMaxHealth = reader.ReadInt32();
                }
            }
        }
    #13920
    Elvin Sim
    Participant
    Helpful?
    Up
    0
    ::

    okok thank you very much, it works now!!!

Viewing 8 posts - 16 through 23 (of 23 total)
  • You must be logged in to reply to this topic.

Go to Login Page →


Advertisement below: