Drop Object on Grid

Hi, I managed to create a grid and my character detects each tiles when steping over them. I can also grab and drop an object, it works rather well. Now what I would like to do is grab an object but drop it only on the center of a grid tile. Anyone has an idea how I would achieve this? Or can point me to a tutorial that could help?

You could snap the object to the center of the tile after it is dropped

float TileSize = ...;
FVector ObjectLocation = Player->GetActorLocation();
// Get the tile start location the player is on
float SnappedTileX= FMath::FloorToInt(ObjectLocation.X / TileSize ) * TileSize;
float SnappedTileY= FMath::FloorToInt(ObjectLocation.Y / TileSize ) * TileSize;
FVector TileStart = FVector(SnappedTileX, SnappedTileY, 0);

// Add an offset to move to the center of this tile
FVector TileCelter = TileStart + FVector(TileSize) / 2.0f;

// Snap the dropped object to the tile center
DroppedObject->SetActorLocation(TileCenter)

Edit: Ah realized this is in the blueprint section. You should be able to convert this to BP. If you need help, let me know

Thanks for replying, I will try with that, but I admit I’m not too familiar with scripting. If you know how to translate it into Blueprint form I’d appreciate. Thanks again.