Hello everyone !
You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
Simply get the raycast function to use the collision group parameter. -
What is the issue? Include screenshots / videos if possible!
I though that I could use raycastParam like this, but I guess I’m wrong.
So my raycast is currently hitting all other my character instead of everything else.
it probably would work by using the array, but I want to make the collision group param work !
Or … does that mean it’s the collision group for the elment inside the array ? The documentation would be… not nice. But I’m going to try it right away.
local RunService = game:GetService("RunService")
RunService.RenderStepped:Connect(function()
local playerPosition = Player.Character:GetPrimaryPartCFrame().Position
local cameraPosition = Camera.CFrame.Position
local rayOrigin = playerPosition
local rayDirection = cameraPosition - playerPosition
local raycastParams = RaycastParams.new()
raycastParams.CollisionGroup = "Player"
local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
print("raycast")
if raycastResult then
print ("collide")
print(raycastResult.Instance.Name)
raycastResult.Instance.LocalTransparencyModifier = 0.5
end
end)
And the player group is settup in another script (I can see the changes)
local Character = Player.Character or Player.CharacterAdded:Wait()
for i,v in pairs(Character:GetDescendants()) do
if (v:IsA("BasePart")) then
v.CollisionGroup = "Player"
end
end
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Looking on the hub but I didn’t find anything as simple as my usecase. And of course I tried another collision group and stuff, but it just doesn’t seems to care.
Have a nice day !