Need Help with some coin logic

  • Hi guys the best way to describe my problem is to relate it to a current game in the hub. You know the game from the hub called Bobs Speedy Adventure. Let’s say I want a way to not have the collected coin spawn in the next round. How would I do that? For example i already collected the coins in the beginning but died later on. When I spawn in those coins I already collected from the beginning are not there any more. How would I achieve this?

  • Don't restart the level, just teleport the player back to the respawn point so the changes made on the level stay.

  • @RobinsonX for my game the player actually enters a secret room which is a different scene. When he returns back to the previous scene is where I want the collected coins to not be there anymore.

  • Ah. The only way you can do this is by using Save to File and Load from File. 🤷‍♂️ @SplitMindGaming

    You want to save what coins you have collected and when reentering back into the scene, you want to load the file with the destroyed coins.

    Of course, you will need a way to identify each coin. Assuming that all the coins will be in the same locations every time, you can reference a coin using its position. When a player collects a coin, note its position. You can add this position to an array (can be formatted like this: x,y) representing all the coins you have collected and save the array.

  • @SplitMindGaming So when reentering back into the scene, load the array with the destroyed coin positions and find all the coin objects with the matching positions to destroy. 😄

    There are many ways you can get the coin object, but I'll suggest the easiest way:

    • Loop through all coins and add a tag to it.
    • This tag will be the initial position of the coin. Can be represented as so: x,y
    • Load the file with the destroyed coin positions - it should be an array.
    • Loop through the array and for each value, use Get Object by Tag to get the coin object with the corresponding position to destroy.

  • @RobinsonX thank you so much for this. I will try it out.

  • @RobinsonX Hi so I was trying to attempt this But tbh I am in no way shape or form a developer. Im not even sure what behavior systems I am suppose to be utilizing. Is it possible to screenshot the behavior systems needed to make this work or even create a mini project of this working. Thanks

  • @RobinsonX I would imagine if a mini project were to be made. A character collecting some coins but intentionally missing some. There could also be a button that reloads the scene and it will pick off where it left off minus the collected coins.

  • @SplitMindGaming I can make a sample project. Hang on!

  • @SplitMindGaming Here's the project:

    Open it in safari if it does not work here. :)

    • You can collect coins and restarting the scene will leave those coins destroyed
    • You can intentionally leave coins behind and those coins will still remain after reloading the scene
    • There is a way to reset the destroyed coins save to revert all the coins to normal

  • @RobinsonX wow thank you so much for this. Im putting you on the ending credits :)

  • @RobinsonX also what would you suggest I study or learn to better understand how to use behaviors like that. Because looking at the file I would have never guessed to use any of those behaviors.

  • @SplitMindGaming Sorry for late response - I actually learned through trial and error!

    I trained myself to study a behavior I want to learn and observe its properties. I know I sound like a nerd, but hyperPad encourages you to be a scientist and over time, you start to learn many processes that you wouldn't expect to grasp on. It ushers you into thinking critically and puts you in a perspective of a programmer.

    I look at a behavior and its reference, form a hypothesis and then test. After a while, I will know exactly what a behavior does and can use it to my advantage.

  • @SplitMindGaming I know some people want guidance on how to learn hyperPad, so I would suggest looking at examples and documentation (yes, video tutorials help too!). But you will need to learn exactly how the behavior system works.

    I'll summarize the behavior system:

    • Behaviors are executed from left to right (there are 2 exceptions)
    • There are 2 types of behaviors: Event and Action
    • Event behaviors tell the behaviors when to execute
    • Action behaviors tell the behaviors what to execute and what to do
    • If an Action behavior is not connected from the top, it will execute immediately when the scene runs

  • @RobinsonX Thanks for this. Honestly if it wasnt for your videos also I would be lost in alot of things. You do a good job of explaining things clearly yet also adding humor to your videos. Great work

Log in to reply