Let’s say I do A Raycast In front of the character head every X seconds, this would work, but what if i get close to a wall and look at it ?, It won’t work, because the raycast doesn’t detect the wall, just the objects behind the wall, why this behavior happens?, Atleast for me, I haven’t seen people talking about this , it’s rare, Maybe I’m missing something?
If someone could Give a solution or a proper explanation if possible would be very very appreciated!
It’s not rare and it usually occurs because the raycast is a bit too infront of the character, set it to start from the HumanoidRootPart’s position and extent outwards, you should also use RaycastParams to filter out the player’s character.
Yes, This is good, but, What if i need to do a raycast gun?, and i need to visualize the bullet beam/part/bullet ?, If i raycast it from the rootpart, it would appear from there
This would put us in a dilemma, since if the raycast is casted from the point of origin of the gun Instead, this same behavior that I mentioned above would be caused again
Let’s say you have an attachment on the muzzle of your gun. Your Direction is the Humanoid’s LookVector. You can do:
local Origin = attachment.WorldPosition
local Direction = HumanoidRootPart.CFrame.LookVector
local Range = 100
local Params = RaycastParams.new()
Params.FilterDescendantInstances = {Character}
local Ray = workspace:RayCast(Origin-Direction*2,Direction,Params)