This repository contains Unity C# scripts for various gameplay mechanics in 3D games.
It includes scripts for player movement, object spawning, collision detection, score and life management, camera following, and background repetition. These scripts demonstrate basic Unity game development skills and can be used as building blocks for small game projects or prototypes.
-
DestroyOfColision_2.cs
- Handles collision with food objects, fills a hunger slider, increments score, and destroys objects.
- Demonstrates collision detection, UI slider manipulation, and object destruction.
-
DestroyOutOfBounds_2.cs
- Destroys objects that go out of bounds and decrements player's lives.
- Demonstrates game boundary management and life tracking.
-
FollowPlayerX.cs
- Makes the camera follow the player with a specified offset.
- Demonstrates camera movement and LateUpdate usage.
-
MoveForward_2.cs
- Moves objects forward continuously.
- Demonstrates object translation and frame-rate independent movement.
-
MoveLeft.cs
- Moves objects to the left and destroys them if they pass a certain boundary.
- Demonstrates player control, object movement, and boundary detection.
-
PlayerController_2.cs
- Handles player movement on X and Z axes, and firing projectiles.
- Demonstrates player input, movement constraints, and instantiation of projectiles.
-
RepeatBackground.cs
- Repeats the background to create a continuous scrolling effect.
- Demonstrates background looping and use of BoxCollider dimensions.
-
SpawnManager_2.cs
- Spawns animals randomly in front of the player and from the sides at intervals.
- Demonstrates object instantiation, randomization, and InvokeRepeating.
-
SpinPropeller.cs
- Rotates propeller objects continuously.
- Demonstrates object rotation and Time.deltaTime usage.
- Unity C# scripting
- Object movement and player controls
- Collision detection and trigger events
- Game UI handling (sliders, score)
- Instantiation and destruction of objects
- Camera control
- Randomized object spawning
- Background scrolling
- Basic OOP concepts in Unity (encapsulation, static variables)
- Open Unity and create a new 3D project.
- Copy all scripts into the
Assets/Scriptsfolder. - Attach scripts to corresponding GameObjects in the scene:
- PlayerController_2 → Player GameObject
- DestroyOfColision_2 → Player or relevant object
- SpawnManager_2 → Empty GameObject as a manager
- RepeatBackground → Background GameObject
- SpinPropeller → Propeller GameObject
- Configure public variables (e.g., sliders, prefabs) in the Inspector.
- Press Play to test the gameplay mechanics.
- Scripts are written for Unity 2020+.
- Ensure prefabs have proper tags (
GameController,Obstacle) for collision detection. - Slider UI elements must be present for hunger/score tracking scripts.
Author: Vladyslav Bezai
GitHub: https://github.com/bezay999