Interaction and Puzzles
Overview
The characters within the game (square sprites at the moment) must obtain watering cans and move towards the plants to water them using the obtained watering cans. The characters can also climb ladders. Each level can be completed when all of the plants have been watered.
Implementation
Prefabs for the Character, Plant and Watering Can have been created.
The Character prefab has Sprite Renderer, Box Collider, Rigidbody, Character Movement Script and Obtain Watering Can Script components. The order in layer for the Sprite Renderer is 2, this is to make the characters appear in front of the ladder and behind the plant. The Box Collider is set to trigger to allow the characters to collide with the Watering Can and Plant game objects. The Character Movement Script contains functionality that enables the characters to climb ladders when the characters have collided with the collider of the ladder which has the tag "Ladder". Obtain Watering Can Script have a boolean variable which becomes true when the characters obtained the watering can and has functionality for destroying the watering can game objects (when the characters have collided with the watering can).
A basic movement functionality for when the characters climb ladders.
A character obtaining a watering can and watering a plant with the obtained watering can with a console tab on top showing the actions of the character.
The Plant prefab has Sprite Renderer, Animator, Box Collider and Plant Watered Script components. The order in layer for the Sprite Renderer is 3, this is to make the plant appear in front of the characters. The controller within the Animator is attached with the PlantController which is the animation for the plant transforming from a dead plant to a living plant. The Box Collider is set to trigger, this is to allow the characters to collide with the Plant game objects. Plant Watered Script have a boolean variable for when the plant has been watered and functionality for the plant animating/changing sprites from the dead plant to the living plant when the characters have obtained the watering can (this script gets the boolean variable for when the characters have obtained the watering can from the character game objects that have collided with the plant) and have collided with the plant.
The Watering Can prefab has Sprite Renderer and Box Collider component. The order in layer for the Sprite Renderer is 0, this is to make the watering can appear behind the characters. The Box Collider is set to trigger to allow the characters to collide with the watering can.
Feedback received
From Jaden:
...I tested your game and I see that is a creative movement, simple gameplay. However it is still containing some issues. I see A and D buttons are not work like description. I think you should not enable trigger for floor, the squares can not move up and down when being in the floor. Apart from the issues I mentioned and the issues you noted in the description, I find the game still quite fine so far.
...I think you should restrict the characters can go through under the floor like this picture, when characters is being below the floor, it cannot move upwards.
Yes, that’s because the characters are colliding with the collider of the ladders. I will resolve this issue later.
References
Some codes were adapted for a number of scripts from the following sources:
- OnTriggerEnter2D or OnCollisionEnter2D not getting called (Gamedev Stack Exchange, unity - OnTriggerEnter2D or OnCollisionEnter2D not getting called - Game Development Stack Exchange)
- Collect & Count Items | Build a 2D Platformer Game in Unity #7 (Coding in Flow, Collect & Count Items | Build a 2D Platformer Game in Unity #7 - YouTube)
- Unity - stop animation loop (Stack Overflow, Unity - stop animation loop - Stack Overflow)
- how to get variables from a script my player is colliding with? (Stack Overflow, unity game engine - how to get variables from a script my player is colliding with? - Stack Overflow)
- How To Make 2D Ladders in Unity (bendux, How To Make 2D Ladders In Unity - YouTube)
Give Water
More posts
- Basic Level BlockingSep 16, 2023
- Character MovementSep 12, 2023
- Game ConceptAug 27, 2023
Leave a comment
Log in with itch.io to leave a comment.