#Improvised Explosive Device - How can I get a rotation of a wall from the players perspective

11 messages · Page 1 of 1 (latest)

amber root
#

"local function updateGhostChargePosition()
if ghostCharge then
local mouse = player:GetMouse()
if mouse.Target then
local mouseHit = mouse.Hit.Position
local mouseTarget = mouse.Target

        local distance = (mouseHit - player.Character.HumanoidRootPart.Position).Magnitude
        local isPlaceable = distance <= 7.5
        
        local TofarPlaceable = distance >= 20
        
        ghostCharge.CFrame = CFrame.new(mouseHit + Vector3.new(0, 0.25, 0))
                    --Here the question
        ghostCharge.Highlight.OutlineColor = isPlaceable and Color3.new(0, 1, 0) or Color3.new(1, 0, 0)
        
        
        if isPlaceable then
            ghostCharge.Transparency =  0
        elseif TofarPlaceable then
            ghostCharge.Transparency =  1
        end
    else
        local mouseHit = mouse.Hit.Position

        local distance = (mouseHit - player.Character.HumanoidRootPart.Position).Magnitude
        local isPlaceable = distance <= 10

        ghostCharge.CFrame = CFrame.new(mouseHit + Vector3.new(0, 0.25, 0))
        ghostCharge.Highlight.OutlineColor = isPlaceable and Color3.new(0, 1, 0) or Color3.new(1, 0, 0)
        ghostCharge.Orientation = Vector3.new(0,0,0)
    end
end

end"

#

I know this might be a bit complicated but I think it would somehow work with rays but i dont know how to use rays

velvet hare
#

because this question can be answered in many ways

amber root
#

So im trying to achieve that the bomb that follows the players mouse takes the rotation of the object its facing against because mouse.Target.Orientation doesent work because the wall could be 0,0,0 but the bomb should stick side ways and btw its a local script that is only making a ghost object for the visuals but im then copying the method to the serverside script

velvet hare
#

so

#

sticky bomb?

#

i got it right?

#

in that case you should use Normals that comes from raycast hit point

#

they tell where the surface is looking

amber root
#

Thanks