ColdRBLX
|
  |
| Joined: 25 Jan 2010 |
| Total Posts: 2446 |
|
|
| 04 Jul 2016 01:33 AM |
| What should be used in order to detect if a player is within 10 suds of the top side of a block, so if they are on top of the block it will detect them up to 10 suds above it? But if they are off the block then it won't do anything. |
|
|
| Report Abuse |
|
|
|
| 04 Jul 2016 01:38 AM |
magnitude, torso.Changed
r+://393244197r+://393244224r+://393244262 |
|
|
| Report Abuse |
|
|
ColdRBLX
|
  |
| Joined: 25 Jan 2010 |
| Total Posts: 2446 |
|
| |
|
Haxelgem
|
  |
| Joined: 18 Jul 2009 |
| Total Posts: 67 |
|
|
| 04 Jul 2016 03:04 AM |
Given a point to test (perhaps the torso's position), try something like this:
function TestPoint(point, part) if (point.x < part.Position.x - part.Size.x / 2) or (point.x > part.Position.x + part.Size.x / 2) or (point.z < part.Position.z - part.Size.z / 2) or (point.z > part.Position.z + part.Size.z / 2) return false return (point.y > part.Position.y) and (point.y < part.Position.y + 10) end
The first if statement checks whether the test point is within the size / 2 of the center of the part. Since the position of a part is the center, the distance to the boundary is equal to the size / 2.
The second returns true if the test point is above the part and below 10 studs above.
This code assumes that the part is facing upwards, and is axis aligned. If that's not the case, let me know and I can revise. I also haven't tested this, so let me know if there's any issues. |
|
|
| Report Abuse |
|
|