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

How would I test out this raycast?

Asked by
parkderp1 105
9 years ago

So I have a script that casts rays based on an object trajectory(without air resistance and other factors), and I want to know how I would test out if the rays go to the right place.

Other parts of the script might have errors, since it's not finished. The raycast is at the bottom

mass=7.45
volume=480.74
density=nil--replace soon!
v=381
aod=0
g=9.81
x=100
y=script.Parent.Position.Y*0.2721428136
--calcdist--
dsec1=(v*math.cos(aod)/g)
dsec2=(v*math.sin(aod))
d=dsec1*((dsec2+math.sqrt((dsec2*dsec2)+2*g*y)))

print(d)

--Airtime--
a=-16
b=v
c=script.Parent.Position.Y
discrim=(b*b)-4*a*c
posx=(-b+math.sqrt(discrim))/(2*a)
negx=(-b-math.sqrt(discrim))/(2*a)
if posx>0 then
    airtime=posx
else
    airtime=negx
end

--Middle--
hsec1=(-g*x*x)/2*(v*math.cos(aod)*math.cos(aod))
hgt=(y+(x*math.tan(aod)))-hsec1


---Velocity---
vsec1=(v*math.cos(aod))
vsec2=(v*math.sin(aod))+((g*x)/(v*math.cos(aod)))

hitvel=math.sqrt((vsec1*vsec1)+(vsec2*vsec2))

hitvelstd=hitvel*3.6745408
print(hitvelstd.." ,"..(d*3.675408).." !"..hitvel.." !2"..d.."midheight: "..(hgt*3.675408))


function castRay()
    local ychange1=(script.Parent.CFrame.lookVector).unit*d/2
    local ray1end=ychange1+Vector3.new(0,-hgt,0)
    local ychange2=(script.Parent.CFrame.lookVector).unit*d
    local ray2end=ychange2
    local Ray1=Ray.new(script.Parent.Position, ray1end)
    local Ray2=Ray.new(ray1end+Vector3.new(0,-script.Parent.Position.Y,0))
end
0
Use workspace:FindPartOnRay()? FutureWebsiteOwner 270 — 9y
0
But that would use a load of trial and error to accurately test it. parkderp1 105 — 9y
0
What exactly are you attempting to test here? What is this script for? TurboFusion 1821 — 9y
0
This script is supposed to represent the arc of a projectile. Im attempting to test whether or not the rays are being correctly cast from the set points parkderp1 105 — 9y
View all comments (2 more)
0
You could draw each ray, if you mean you don't know how to see if it's arcing correctly. Goulstem 8144 — 9y
0
How would i draw each ray? parkderp1 105 — 9y

Answer this question