
Learn to build a 3D battleships game in Unity, featuring main menu and game scenes, an npc opponent for 1v1 play, and ship placement with ghost objects and snap rotation.
Discover how to build a 3d battleships game with a 10 by 10 grid, ship placement and rotation, ghost checks, and turn-based shooting between human and ai players.
Set up a unity project via unity hub, choose version and 3d or 2d, name and locate it, arrange console, game view, scene, inspector, project window, and save your layout.
Set up the first tile by creating a centered 3d cube, applying a blue tile material with a four-sprite highlight, and slicing sprites for mouse interaction and tile positioning.
Create a tile info script in Unity to store axial positions and shot status, and activate tile highlights via a sprite renderer when the mouse hovers.
Automate a 10 by 10 play field in Unity by creating a tile prefab, scripting automatic tile instantiation, and filling coordinates, then visualize and verify with the inspector.
Animate water UV in Unity by scrolling texture offsets on the U and V axes according to a scroll speed, applied to tile prefabs and updated at runtime.
Place management system handles ship ghosts, activates and deactivates placing mode, checks valid tile positions on the play field, and spawns ship prefabs from a serialized ships-to-place list.
Continue implementing the placing manager by casting a ray from the camera to detect valid tile positions, store hit points, and preview a ghost on the grid.
Create cube-based ghost ships with transparent materials to visualize placement above the board. Implement ghost behavior with downward raycasts, tile detection, and 90-degree rotation around a bottom pivot.
Implement a function in the placing manager to deactivate all ghosts, then activate the target ghost by index (or deactivate all when -1), while avoiding reactivating already active ghosts.
Implement tile checks and ship placement in Unity for a 3D battleships game using ghost ships to preview placement, validating no overlap and toggling activation.
Parent all ship ghosts under the placing manager and assign them to ghost slots for cruiser, destroyer, submarine, battleship, and carrier, then enable the play field layer to filter placement.
Preview ghost ship placements on the play field by projecting tiles under the mouse and validating with a downward ray, supporting rotation for all ships.
Create a ship behavior system that uses ship length to determine hit points, track hits, detect sinking, and report status to the game manager in Unity Battleships 3D.
Place ships in battleships 3d by instantiating ship prefabs at the rounded hit position, aligning rotation with the ghost, and updating the placed list and grid during placing mode.
Design and export vector ship buttons in Inkscape, turning ship screenshots into clickable Unity UI elements. Duplicate and resize graphics, arrange text, and prepare PNG exports for import into Unity.
Create a canvas with a background image and sprite-sliced buttons, anchored and scaled to screen size, to control placing mode with carrier, battleship, submarine, destroyer, and cruiser.
Limit ship placement in the Unity Battleships 3D tutorial. Update the placed amount and deactivate the ghost after placement, turning off all ghost ships until all ships are placed.
Builds a game manager with a static instance and a serializable player class, initializes a 10x10 tile grid with occupation and revealed states, tracks the active turn.
Update grid in Unity battleships course by managing a game manager, tracking placed ships via the placed ship list, and syncing tile info with ship transforms to reflect occupation types.
Update the grid when placing ships and debug the grid by printing to the console, passing the ship ghost transform and ship behavior to the game manager.
Debug to ensure ships load correctly, verify the destroyer spawns and rotates its orientation by 90 degrees, and confirm tiles reflect occupancy with b markers to prevent overlaps.
Implement a public boolean function checkIfOccupied in the game manager to verify whether a tile on the active player's grid is already occupied, preventing ships from overlapping.
Visualize and track remaining ships in battleships 3d by connecting text fields to each ship button, updating counts in placing manager, and reflecting placements in real time.
implement a clear all ships button by updating the game manager to reinitialize the grid, destroy placed ships, and refresh the placed counts and user interface via the placing manager.
Enable the ready button only after all ships are placed by checking each ship's placed amount, updating the button state and color, and notifying the game manager to proceed.
Isolate each player's play field in Unity and route placement through the placing manager fed by the game manager, ensuring ships go to the correct field and tiles are initialized.
Learn to implement a game state machine in Unity to control the flow of battleships 3D, including states for player one placement, player two placement, idle, and shooting.
Hide all panels, then show the first player's placing panel, use the state machine to set idle, and move the camera to the relevant field to begin the first turn.
Design a height overlay panel to block raycasts on the placing canvas, using a bottom canvas, a black image with alpha, and manage panel activation for player ship placement.
drives the preparing phase by handling ready state, switching active players, hiding ships, moving the camera, and enabling the placing panel for the next player until the actual game begins.
Switch the active player by incrementing and wrapping with modulo to zero after two, then call switch player after placement and save the game manager.
Define three camera points for placing and gameplay in Unity battleships 3d, store exact world space positions and rotations, and visualize the full playfield across resolutions.
This lecture explains implementing the ready button to start the core move camera routine for the active player, toggle placing panels and canvases, and switch to the battle camera.
Enable auto ship placement in Unity Battleships 3D by implementing a place ships button and a placing manager that randomizes positions and rotations and validates with a ghost.
Fixes a minor bug in the auto place ships flow by ensuring the ready button disables when clearing all ships or during placement, preventing an empty play field.
activate the shooting state by hiding non-target panels, deactivating your own ships, and switching the game state to shooting, enabling players to click the opponent’s tiles and watch turn transitions.
Update tile info during the shooting phase by consulting the game manager for shot coordinates and showing a crosshair only if the tile isn’t shot yet.
Determine the opponent by deriving the active player, incrementing it, applying modulo, then returning the opponent from the game manager to access the corresponding tile during the shooting phase.
Implement a check coordinate function that accepts x and y and tile info to validate shots on the opponent's play field, prevent shooting yourself, and provide debug feedback.
Validate shot coordinates by querying the opponent's revealed grid, check tile occupancy, activate highlights, update the reveal grid, and switch the turn to refine the battleship 3D shooting logic.
In this check shot session, the game manager processes hits by calling ship.takeDamage, updating hit points, destroying sunk ships, removing them from opponent grids, and evaluating win conditions.
Implement a win check by testing if the placed ships count on the opponent’s board is zero, then print you win and trigger win logic such as changing scenes.
Update the check shot flow in the unity battleships 3d game by advancing turns, validating tile occupancy, triggering win logic, and visualizing shots with rockets, highlights, and a three-second wait.
Develop NPC AI for battleships 3D by scanning revealed tiles, handling partially revealed ships, and implementing directed shooting logic against the opponent.
Select a random neighbor from the revealed cells, compute the x and z coordinates, fetch the tile info from the play field, and shoot; if no hit, try downward shots.
Store unrevealed tiles in a new random shot list to prevent duplicates. Select a random tile from list, reveal it, check neighbors, update tile info, and execute the NPC shot.
Automate NPC ship placement in battleships 3D by triggering ready state, switching active player, and moving the battle cam for seamless NPC turns.
In this Course you'll learn how to create a Battleships 3D with Unity Engine. Pen and Paper games like Battleships are also quite popular even on mobile or pc. I will show you step by step how you can create Batlleships 3D.
This course is a Beginner/Intermediate course, so if you have trouble in any case, write me a message or Q&A, and i'll help as best as i can.
If you are beginner, you might have some trouble to follow, but the videos will guide you through the complete course. Don't forget you only become better if you repeat things and keep on learning!
So we create Systems which will give us the freedom to:
C# (Monodevelop)
Placing mechanism to place all Battleships in a 3D
A statemaschine to handle all players / cpus
Turn base game play
AI which is able to play completely alone
Unity (2019.1)
we create a playfield
we create a GameManager
we create a main menu scene where we can pick who wants to play
we create a game over scene panel
Course Material
I provide the following Material with the Course:
5x Ship 3D Model
1x Rocket 3D Model
7x Button Graphics 2D
1x Tileable Water Texture 2D
You have to write the code on your own, i do not provide the final scripts!
All other graphics for Menu's, Icons, Images or Buttons need to be created on your own.
All Materials i provide are for education only and should not be in your final release!
Conclusion
In the end of this course you will have a fully functional Battleships 3D Game.
Challenge
After you have created nice Menus, Buttons, and maybe additional content, upload the Game to any Gaming Website, Google Playstore, Apple Store or even Windows Store or Steam.
So what are you waiting for?
Let's make your dream game a reality!!
Level: Beginner
Video Course Length: ~9.5 hours
Unity Version required: 5.3+