Forum begins after the advertisement:

[part 8] resetting ability unlocks

Home Forums Video Game Tutorial Series Creating a Metroidvania in Unity [part 8] resetting ability unlocks

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
  • #13825
    Anuk Thotawatta

    After i gain the ability and the unlockDash,unlockDoublejump and unlock walljump objects no longer appear, how do i make them re appear for testing purposes.

    also the game dident allow me to pick up the abilities they just disappeared and i had the ability as soon as i saved my code and ran the game.

    Anuk Thotawatta

    View post on

    why is this happening. i saved the game and reloaded just like in the video but the error is still there.

    Joseph Tang

    Hey there, could you try showing us the PlayerController.cs Start()?

    For the issue of the Player floating above the ground and not falling;

    There’s a likely chance that the your code has SaveData.Instance.LoadPlayerData(); before your gravity scale is set.
    Your gravity = rb.gravityScale; is commented out in the Start().

    After fixing your player character, can you show me an image or video of your player collecting the abilities so i can get a visual example of the issue.

    Anuk Thotawatta
     void Start()
            pState = GetComponent<PlayerStateList>();
            rb = GetComponent<Rigidbody2D>();
            sr = GetComponent<SpriteRenderer>();
            anim = GetComponent<Animator>();
            SaveData.Instance.LoadPlayerData(); //if player falls through ground because of changes comment this line ---------IMPORTANT
            gravity = rb.gravityScale;
            Mana = mana;
            manaStorage.fillAmount = Mana;
    Anuk Thotawatta

    i moved gravity scale up. player doesnt float anymore but i still get the error and i cant save the scene im in

    View post on

    Joseph Tang

    I find this case quite confusing.
    Looking at the only error in the Console, it may have something to do with the lastScene = reader.ReadString(); in SaveData.cs under “LoadPlayerData(). Perhaps it cannot read it correctly and prevents the following code below it from working [The code regarding the abilities]

    1) Could you help test if the save data isn’t working or if the load data isn’t working.

    just put print(SaveData.Instance.lastScene); under your pause control [In Update() for GameManager.cs: if (Input.GetKeyDown(KeyCode.Escape) && !gameIsPaused).

    Then put print(SaveData.Instance.lastScene); again under the PlayerController.cs Start(): SaveData.Instance.LoadPlayerData();

    2) Could you test if SaveData is unable to function properly due to the lastScene code?

    Try commenting out the code relating to lastScene in the SaveData.cs, then try picking up the abilities again to see if they are being saved and loaded again.

    I cannot confidently say this is the issue since your LoadPlayerData seems to be functioning correctly so far and the code is 1:1 for how it’s typed and should work.

    Anuk Thotawatta

    you were right. my lastscene = reader.ReadBString(); was above my playerabilityunlocked = reader.ReadBoolean(); .
    i moved it below and every thing seems to work fine. thank you so much

    Joseph Tang

    That’s great, but considering you would want to have your load scene data to work, how’s the load data function now?

    Can you load into your saved scene?
    If not, can you try saving in other scenes? Perhaps (for some reason since it should be fine.) the name of the scene is the issue.

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

Go to Login Page →

Advertisement below: