I’m wanting to to always check if there’s a wall to one side of a player
I have this, but it seems to depend what direction the player is facing. I don’t want this however.
local RaycastCheck = workspace:Raycast(
Character:GetPivot().Position,
Vector3.new(0, 0, RandomOffset == 1 and -20 or 20),
Params
)
I want to know if there’s a wall next to a player, regardless of what way the player is looking, as i want to check if a player is behind a wall when another part comes through
You probably need to change from Raycast to Region3
Raycasting always cast in a straight line no matter what. If you want to achieve that using raycasting technique, you may need tons of rays. instead please do consider using Region3
In order to check which side of the wall is to player, just manipulate Position or CFrame of the player to walls.
Couldnt you just have the rayDirection set to Vector3.new(100,0,0) then change the 100 to -100 depending on which side red wall is coming from? Also just change 100 to a smaller number if you want player to be closer to the wall.
Then use the combination of Region3 and Raycast. You will use Region3 to detect if you are close to the blue wall. Then detect which side the blue wall is at. Then shoot a ray to that direction, to see if you detect a red wall. If it detects, the player lives, otherwise, dies.
you’d get the dot product between the direction from blue to red and the direction from blue to player position?
If the dot product is near enough to 1 then they should be damaged since they are both on the same side.
They should not be damaged if the dot product is around -1 though.
That shouldnt be the case considering you are just shooting a ray in one direction instead of giving it players lookvector, are you sure there isnt some other part of the code messing with it?
This is what I have been thinking about it also. Since rayDirection can be from anywhere, then why is it shooting out from where the player is looking at instead?