RaycastResult Normal ignores lookvector for some reason

Hello,

I’m trying to make a move for my game that makes the player throw a small landmine onto a wall, and the top of it will face away from the wall

The two circles represent the top and the front of the object
image

I’m using RaycastResult.Normal to determine which way the mine will face, and I tried using LookVector as a direction for the raycast, but for some reason it ignores the LookVector of the mine. I don’t know why that is.

    local mine = game.ReplicatedStorage.Projectiles.Landmine:Clone()
	mine.Parent = workspace
	mine.CFrame = cf * CFrame.new(0,1,-3)
	local landminePos
	local landed = false

	local part = Instance.new("Part",workspace)
	part.Anchored = true
	part.CFrame = mine.CFrame * CFrame.new(0,0,-5)
	part.CanCollide = false
	part.Transparency = 1
	game.Debris:AddItem(part,0.1)
	
	local BV = Instance.new("BodyVelocity",mine)
	BV.MaxForce = Vector3.new(100000,100000,100000)
	BV.Velocity = mine.CFrame.LookVector * 40
	BV.Velocity = BV.Velocity + Vector3.new(0,8,0)
	game.Debris:AddItem(BV,0.04)
	
	local look = part.CFrame.LookVector 
	local PartPos = part.Position

	---- This doesn't seem relevant to the problem ----
	repeat
		local ray = Ray.new(mine.Position,Vector3.new(0,-1.5,0))
		local ray2 = Ray.new(mine.Position,(mine.Position - PartPos).Unit * 2)
		local hit,position
		local list = {mine,char}
		local finalPos
		local finalHit
		local maxHit = 5
		
		for i = 1, maxHit do
			hit,position = workspace:FindPartOnRayWithIgnoreList(ray,list)
			list[#list + 1] = hit
			if rayFilter(hit) then
				finalPos = position
				finalHit = hit
				break
			end
		end
		
		for i = 1, maxHit do
			hit,position = workspace:FindPartOnRayWithIgnoreList(ray2,list)
			list[#list + 1] = hit
			if rayFilter(hit) then
				finalPos = position
				finalHit = hit
				break
			end
		end
		
		if finalHit then
			landed = true
			landminePos = finalPos
		end
		game:GetService("RunService").RenderStepped:Wait()
	until landed == true
-------------------------------------------------

		local ray2 = workspace:Raycast(mine.Position,Vector3.new(0,-2,0))
		if ray2 and ray2.Instance.CanCollide == true and ray2.Instance.Parent:FindFirstChild("HumanoidRootPart") == nil then
	end
	
	mine.Position = landminePos
	mine.Anchored = true

------- v  Here's the real problem  v -----	
	local rrray = workspace:Raycast(mine.Position,look * 5) --- This is most likely the source of the problem
	if rrray then
		mine.Orientation = rrray.Normal
		mine.Orientation = mine.Orientation + Vector3.new(0,0,90)
	end

Here is the result of this:
image
It only rotates when placed on specific walls when I want it to apply to all walls

Instead of setting the mine’s orientation property, try setting its CFrame.

image from API reference of CFrame

Afterwards, you will have to offset the relative rotation of the mine so that it aligns with the wall.

mine.Orientation = rrray.Normal
mine.Orientation = mine.Orientation + Vector3.new(0,0,90)

becomes

mine.CFrame = CFrame.new(landminePos, landminePos + rrray.Normal) * CFrame.Angles(-math.pi/2,0,0)

The exact same thing occurs when I use CFrame

The lookvector never changes from what was set at the start.

local look = part.CFrame.LookVector 

You need to update it to point where your mouse is clicking relative to your body.
You will have to replace ROOTPART with the reference of your own character’s rootpart.

look = (landminePos - ROOTPART.Position).Unit
local rrray = workspace:Raycast(mine.Position,look * 5)

The problem is, no matter what, the raycast ignores the lookvector, regardless of whether it’s been updated or not