I want to create a game similar to sea battle 2 ! how can i do in ue4?

There’s probably half a dozen ways of doing it, here’s one:

I added a custom Game Mode with a Player Controller to keep things civil and organised.

  • I spawned some physics ‘ships’ above the board and let them fall with physics and gravity
  • the script then checks what’s under the cursor, if it’s a Ship, we store a reference
  • switch the physics and collision off so it does not interfere with anything else while we drag it around
  • then we check what’s under the cursor; if it’s a tile, we interpolate the ship’s location to the location of that tile - this gives the movement a nice, smooth snap. The ship also is lifted 100uus above the tile, so it looks like it’s floating while it’s being dragged
  • when the mouse is released, we snap the ship to the last known tile’s location (in case the interpolation did not finish) and clean up

Image from Gyazo

There’s obviously tons of work to do here but it could be a fun and challenging learning (or even commercial, who knows how you spin it) project.