Welcome to the Enchanted Village! đŸŒģ✨
Nestled in a lush, green valley surrounded by rolling hills and sparkling streams, the Enchanted Village is a whimsical paradise where joy and harmony flourish. The villagers live simple, happy lives, growing their own food in sunlit fields filled with golden wheat, vibrant flowers 🌷, and juicy orchards 🍎. Every day is filled with laughter, music đŸŽļ, and the warm glow of community spirit.
At the edge of this magical land lies the Mushroom Village 🍄, home to the delightful Mushroom People! These tiny, cheerful beings live in cozy mushroom-shaped houses and spend their days crafting beautiful trinkets, dancing under the moonlight 🌙, and sharing their wisdom with curious visitors.
But not all is peaceful... Far to the icy north â„ī¸, banished to the snowy Arctic, lives the Wicked Witch đŸ§™â€â™€ī¸. Her heart, as cold as the tundra, holds a grudge against the village for casting her out long ago. While the villagers whisper tales of her dark magic, they remain unshaken, knowing that the warmth of their unity and the courage of their Mushroom allies will always protect their enchanted home
Explore the enchantment, uncover secrets, and immerse yourself in this magical VR world! 🌟
Core Functionality
Keyboard Movement (WASD/Arrow Keys): 🎮
- The player can move forward/backward (W/S or âŦ†ī¸âŦ‡ī¸ Arrow Keys) and strafe left/right (A/D or âŦ…ī¸âžĄī¸ Arrow Keys).
- The movement direction is calculated using the player's forward 🧭 and right â†”ī¸ vectors, multiplied by the movement speed 🚀 (moveSpeed) and frame time âŗ (Time.deltaTime).
Mouse Horizontal Rotation (Y-axis): đŸ–ąī¸â†Ēī¸
- Moving the mouse horizontally rotates the player object around its Y-axis 🔄.
- Mouse X input determines how much the player rotates horizontally based on mouseSensitivity đŸŽšī¸.
Keyboard Horizontal Rotation (Y-axis): đŸ”„âŒ¨ī¸
- Left and right rotations can also be controlled using the A/D keys or âŦ…ī¸âžĄī¸ Arrow Keys.
- Rotations happen at the speed defined by rotationSpeed đŸŽī¸.
Mouse Vertical Rotation (X-axis): đŸ–ąī¸âŦ†ī¸âŦ‡ī¸
- Moving the mouse vertically rotates the camera đŸŽĨ around its X-axis, allowing the player to look up 👆 and down 👇.
- The script uses rotationX â†•ī¸ to track and clamp the vertical rotation between -90° and 90° ❌🔄 to prevent unnatural flipping.
Camera Control: đŸŽĨ👀
- The playerCamera (child of the player) is rotated independently for vertical movement, while the player object only rotates horizontally â†”ī¸.
Code Highlights 🏆
moveSpeed 🚀 and rotationSpeed 🔄:
- Control how fast the player moves and rotates.
mouseSensitivity đŸ–ąī¸đŸŽšī¸:
- Adjusts how sensitive the mouse movements are for smoother gameplay.
Smooth Movement and Rotation: âŗđŸŽŽ
- Multiplying movement and rotation speeds by Time.deltaTime ensures that the motion is consistent across devices, no matter the frame rate.
Clamping Vertical Rotation: đŸšĢâ†•ī¸

- Limits how far the camera can tilt up 👆 or down 👇 using Mathf.Clamp, ensuring a natural range of motion.
How to Use: đŸ› ī¸đŸŽŽ
- Attach this script to the player GameObject đŸ•šī¸.
- Assign the camera GameObject đŸŽĨ (child of the player) to the playerCamera field in the Unity Inspector.
Play the scene and control the player with:
- W/A/S/D or Arrow Keys for movement âŦ†ī¸âŦ‡ī¸âŦ…ī¸âžĄī¸.
- Mouse for looking around đŸ–ąī¸đŸ‘€.
- Optional: Use A/D or Left/Right Arrow for explicit horizontal rotation 🔄.
Enhancements (Optional): 🌟💡
- Add jumping functionality 🚀 using Input.GetKeyDown(KeyCode.Space).
- Add smoothing đŸŽšī¸ to the camera rotation for a more polished experience ✨.
- Integrate physics-based movement âš™ī¸ for a more realistic character controller.
Come take a look!
You can find this project and many more in my Github repositories!
Back to Top