I can’t find a way to move the ray forward depending on the lookVector. What I thought I wrote was working, but it only moves it globally.
How do I move the raycast origin position forward only based on lookvector?
I can’t find a way to move the ray forward depending on the lookVector. What I thought I wrote was working, but it only moves it globally.
How do I move the raycast origin position forward only based on lookvector?
Try
local origin = mouseOrigin.p + (charLookVector * 10)
It worked, thank you so much!!
I tried something similar before, but the difference between yours and mine, is that I didn’t multiply it by 10, thanks!!
Do you think you know how to inverse the mouseOrigin.P’s Y values?
If you look up or down, the ray is like this:
Could you elaborate more on what you’re trying to do?
Hehe, yeah sorry… so basically if the ray coincides with the mouse.Target (if they detect the same part), then it won’t place a surface… if they don’t coincide, it means you’re aiming at the floor.
So… let me show you this:
If the ray detects a different part from the mouse.Hit, it will place down the surface… but since the camera’s ray is kind of inverted, this will set to true and may place a surface on somewhere where I don’t want it to be
Where are you raycasting to and from?
Actually I think I can just pick the X and Z axis, and forget the Y so it doesn’t cause that… but now my question is how can I pick those 2 if the ray requires a position with a Vector3?
Raycasting from the mouse.Origin, therefore the camera, going towards a part, and searching if the part coincides with the mouse.Hit
Let me give you the code:
if result and playable == true then
if (mouseTarget.Orientation.Z <= -5 or mouseTarget.Orientation.Z >= 5) or mouseTarget ~= result.Instance and (mouseHit.p - clone.Position).Magnitude <= 10 then
hasTriggered = true
local surfaceClone = surfaceRX:Clone()
surfaceClone:SetAttribute("surElement", "water")
surfaceClone.Parent = workspace
surfaceClone.Position = mouseHit.p
surfaceClone.hitBox.Position = mouseHit.p + Vector3.new(0,1,0)
surfaceClone.Rotation = Vector3.new(0, 0, 90)
if hit.Name == "groundSurface" and hit:GetAttribute("surElement") == "fire" then
-- ToDo Make Steam Logic
debris:AddItem(hit,0)
end
end
This detects if it’s a ramp or a floor…
So if I’m understanding correctly, you want to place the surface part if the raycast hits a floor?
a floor or a angled floor, yess.
edit: Technically the ray is searching for a wall, to then say - “This is a wall, I’m looking for a floor, so if anything is diffrent than a wall, then place a platform”
edit2: I hope you get me…
Your method of detecting if it’s a floor is a bit flawed. I recommend using the raycast result’s normal. You can verify if it’s a floor if the Y component is a value greater than 0.
I did that this is my 5th try on making it, and this method was the only one that worked so far… maybe I did the others wrong
This has been killing my brain I have since yesterday working on it.
The raycast normal solution isn’t working?