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
- This topic has 7 replies, 2 voices, and was last updated 4 months, 4 weeks ago by
Joseph Tang.
-
AuthorPosts
-
April 10, 2024 at 9:07 pm #13825
Anuk Thotawatta
Participant::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.
April 10, 2024 at 11:02 pm #13826Anuk Thotawatta
Participant::why is this happening. i saved the game and reloaded just like in the video but the error is still there.
April 11, 2024 at 1:54 am #13827Joseph Tang
Moderator::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 yourgravity scale
is set.
OR
Yourgravity = rb.gravityScale;
is commented out in theStart()
.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.
April 11, 2024 at 2:10 pm #13830Anuk Thotawatta
Participant::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; }
April 11, 2024 at 2:16 pm #13831Anuk Thotawatta
Participant::i moved gravity scale up. player doesnt float anymore but i still get the error and i cant save the scene im in
April 11, 2024 at 11:41 pm #13835Joseph Tang
Moderator::I find this case quite confusing.
Looking at the only error in the Console, it may have something to do with thelastScene = 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 [InUpdate()
for GameManager.cs:if (Input.GetKeyDown(KeyCode.Escape) && !gameIsPaused)
.Then put
print(SaveData.Instance.lastScene);
again under the PlayerController.csStart()
: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.April 12, 2024 at 1:14 am #13837Anuk Thotawatta
Participant::you were right. my
lastscene = reader.ReadBString();
was above myplayerabilityunlocked = reader.ReadBoolean();
.
i moved it below and every thing seems to work fine. thank you so muchApril 12, 2024 at 1:16 am #13838Joseph Tang
Moderator::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. -
AuthorPosts
- You must be logged in to reply to this topic.
Advertisement below: