Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do I make a ray detect terrain that it's inside of?

Asked by 4 years ago

I'm editing a model's scripts for raycasting, and I'm handling rays detecting terrain. The way that they do it is have a repeat runService.heartbeat:Wait() and make the ray below in that function. But what tends to happen is that when the cannonball (i'm scripting the cannon ball) is made, the ray clips through and ends up registering the terrain at the bottom of the terrain side, like as if a ray had been generate INSIDE the terrain. Is there an option to enable the ray to detect anything that it's inside of?

here's a little snippet of code that I have for the ray. If you need more details just let me know.

repeat runService.Heartbeat:wait()
        NonWeapon = NonWeapon + 1
        local CF = CFrame.new((Vector3.new(0, -workspace.Gravity/4, 0))*timeSince^2 + (startCF.lookVector * BulletVelocity) *timeSince + startCF.p)
        Projectile = CF
        Projectile = CFrame.new(Projectile.p, aimFor)
        local ray = Ray.new(Projectile.p, (((Projectile * CFrame.new(0, 0, -1)).p - Projectile.p).unit) * (BulletVelocity/50))
        local part, position, normal, material = workspace:FindPartOnRayWithIgnoreList(ray, IgnoreList, false, true)
        if part then
            print(part:GetFullName())
        end
0
what do you mean by that like what its parent or maybe its positioning is inside the terrain spectacularnicknack 2 — 4y

Answer this question