Meshpart is with out hitbox in new vertex

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Right now, I’m starting with a simple task: trying to move something up and down based on a MeshPart vertex’s Y position, like a ball in the ocean.

  2. What is the issue? Raycast does not detect new vertices created. Maybe EditableMesh needs an update Physics function, as we see in the image below:

The triangle wave-looking mesh with blue details is the ocean project mesh, and the yellow ball is the origin vector for the raycast, while the red one is the final vector of the raycast. As we can see in this script:

local origin = Vector3.new(-310.75, 6, -132.25)
local direction = Vector3.new(-310.75, -6, -132.25)
local rayDirection = direction - origin
local oceanMesh = script.Parent
wait(2)	

if oceanMesh then
	local raycastParams = RaycastParams.new()
	raycastParams.FilterType = Enum.RaycastFilterType.Include
	raycastParams.FilterDescendantsInstances = {oceanMesh}

	local result = workspace:Raycast(origin, rayDirection, raycastParams)

	if result then
		local hitPosition = result.Position

		-- Visualizar o ponto de impacto com uma esfera
		local hitMarker = Instance.new("Part")
		hitMarker.Shape = Enum.PartType.Ball
		hitMarker.Name = "Mario"
		hitMarker.Position = hitPosition
		hitMarker.Size = Vector3.new(1, 1, 1)
		hitMarker.Anchored = true
		hitMarker.BrickColor = BrickColor.Red()
		hitMarker.Parent = workspace

		print("Hit part: " .. result.Instance.Name)
		print("Hit position: " .. tostring(hitPosition))
		return result
	else
		local startPos = Instance.new("Part")
		startPos.Shape = Enum.PartType.Ball
		startPos.Name = "StartMark"
		startPos.Position = origin
		startPos.Size = Vector3.new(1, 1, 1)
		startPos.Anchored = true
		startPos.BrickColor = BrickColor.Yellow()
		startPos.Parent = workspace
		local endPos = Instance.new("Part")
		endPos.Shape = Enum.PartType.Ball
		endPos.Name = "EndMark"
		endPos.Position = direction
		endPos.Size = Vector3.new(1, 1, 1)
		endPos.Anchored = true
		endPos.BrickColor = BrickColor.Red()
		endPos.Parent = workspace
		print("No hit")
	end
else
	print("Ocean part not found in workspace.")
end
  1. What solutions have you tried so far? Another way to do what I’m trying to achieve is by using FindClosestVertex, but I don’t want to. I forgot to mention that the MeshPart is not originally a plane; it is a cube that has had its vertices modified and turned into a plane with 10k triangles, as shown in this image:

    and when the script runs:
    image

What i tried so far.

I tested placing the raycast in the same location as the original cube, and somehow it detected a ghost cube there. So I can assume that the hitbox is not updating when creating the new vertices, maybe because EditableMesh is still a beta version.

Thanks to anyone who is helping me with this.

2 Likes

Btw, the meshPart changes colors because I have the Studio Visualization option ‘Show Geometry of Decomposition’ turned on.

1 Like

An editable mesh only changes a parts appearance. The parts collisions stay the same so that’s why you’re running into the invisible block issue when raycasting

1 Like

Oh thanks, how i can update the hitbox of the mesh

iirc, the only way is by using bones and animating it. I’m not too familiar with editable mesh because it is in beta, but have you tried using FindClosestPointOnSurface(), FindClosestVertex(), GetPosition(), or RaycastLocal()? Saw it on the documentation:

1 Like

sorry for my late (yes i fall a sleep), i even know if you are goin to read this comment, but if so.

I tried raycastlocal but does not work, maybe its patched because if i remember raycastlocal was supose to function just for editable mesh right, if that is soo im goin to quit editable mesh and return when is not beta, this is sad bec editable mesh is soo incredible, btw can you tell me if editable mesh in the future will change vertex collisions too. thanks :smiley:

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