Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 04 Jun 2016 05:14 PM |
So I've made my ray between a part, and a Vector.new(0,1,0).unit
How can I determine the distance between these things by using the ray?
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 04 Jun 2016 05:16 PM |
After reading this twice, it's a bad question.
Basically what I'm trying to do is calculate how many "steps" I'd need a falling object to descend in order to reach ground level (ground level will vary constantly)
Should I be using a ray for this in the first place?
|
|
|
| Report Abuse |
|
|
|
| 04 Jun 2016 05:17 PM |
| If the ray makes contact with something, using FindPartOnRay (?) (thats not the name, look it up bc i dont remember) and the position value on it, you can use magnitude between the position and the origin of the ray |
|
|
| Report Abuse |
|
|
|
| 04 Jun 2016 05:17 PM |
| yes, you do want a ray for this |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 04 Jun 2016 05:20 PM |
So, the ground is made of Terrain, I would say something like...
local ray = Ray.new(Model1.PrimaryPart.CFrame.p,(Vector3.new(0,1,0).unit))
local hit, position = workspace:FindPartOnRay(ray, p.Character) if hit:IsA'BasePart' then -- here, how do I determine distance to the end of the ray? end
|
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 04 Jun 2016 05:21 PM |
And also, do I have to say
if hit:IsA'BasePart' or hit:IsA'Terrain' then -- do stuff end
?
|
|
|
| Report Abuse |
|
|
|
| 04 Jun 2016 05:22 PM |
| print((Model1.PrimaryPart.CFrame.p-position).magnitude) |
|
|
| Report Abuse |
|
|
|
| 04 Jun 2016 05:23 PM |
| And if the className for terrain is "Terrain" then yeah use that |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 04 Jun 2016 05:24 PM |
The classname for Unions is UnionOperation, and the classname for Parts is Part, but they still somehow identify as a BasePart.
|
|
|
| Report Abuse |
|
|
|
| 04 Jun 2016 05:26 PM |
| Then have it print the className of the terrain, then just say IsA(whatever it tells u it is) |
|
|
| Report Abuse |
|
|
ray_1
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 464 |
|
|
| 04 Jun 2016 05:28 PM |
IsA() will take into account of inherited classes, and pretty much all types of parts inherit from BasePart. Also, Terrain inherits from BasePart as well so you only need IsA("BasePart")
Recommended username: PainfulRay_1
|
|
|
| Report Abuse |
|
|
| |
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 04 Jun 2016 05:29 PM |
Thanks, I thought so but wasn't sure.
|
|
|
| Report Abuse |
|
|