How to determine what could be underneath a vector3value?


if a Vector3Values’ value represents the position somewhere in the picture. How can I determine what could be underneath it?
The system I’m trying to replicate is very similar to Rise of Nations, where if you move your army onto water it turns it into a boat model.
All I have on the server is a vector3Value which represents the armies position, and the armies model is replicated on the client.
I also need the server to realize that the army is on water, so how could I go about doing this?

1 Like

you could utilize a hit.Parent with the mouse to check n see if the part your clicking on is either blue, or if the part is named water, and do that accordingly, or have a .touched event inside of the water that changes the army model when they’re on it or vice versa, honestly im not too sure, just giving suggestions

Raycast straight down from above the point.

E.g.

local TagS = game:GetService("CollectionService")

local UP = Vector3.yAxis
local DOWN = -Vector3.yAxis
local FIND_TERRAIN_PARAMS = RaycastParams.new()
FIND_TERRAIN_PARAMS .FilterType = Enum.RaycastFilterType.Include

function isPointInWater(point: Vector3): boolean
    FIND_TERRAIN_PARAMS .FilterDescendantInstances = TagS:GetTagged("Terrain")
    local result = game.Workspace:Raycast(point + 10 * UP, DOWN * 20) --
    if not result then error(("You shouldn't check if points outside the map (%s) are in water. Did you mean to check a different point?"):format(tostring(point)) end
    return TagS:HasTag(result.Instance, "Water")
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.