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
    Posts
  • #13825
    Anuk Thotawatta
    Level 4
    Participant
    Helpful?
    Up
    0
    ::

    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.

    #13826
    Anuk Thotawatta
    Level 4
    Participant
    Helpful?
    Up
    0
    ::
    View post on imgur.com

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

    #13827
    Joseph Tang
    Level 13
    Moderator
    Helpful?
    Up
    0
    ::

    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. OR 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.

    #13830
    Anuk Thotawatta
    Level 4
    Participant
    Helpful?
    Up
    0
    ::
    <code> 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;
        }</code>
    #13831
    Anuk Thotawatta
    Level 4
    Participant
    Helpful?
    Up
    0
    ::

    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 imgur.com
    #13835
    Joseph Tang
    Level 13
    Moderator
    Helpful?
    Up
    0
    ::

    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();


    1. 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.

    #13837
    Anuk Thotawatta
    Level 4
    Participant
    Helpful?
    Up
    0
    ::

    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

    #13838
    Joseph Tang
    Level 13
    Moderator
    Helpful?
    Up
    0
    ::

    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: