C_Sharper
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 6405 |
|
|
| 14 Sep 2016 11:43 AM |
Isn't this how it would be done?
local object1 = obj local object2 = obj2
if object1.Position.Y + Vector3.new(0,object1.Size.Y,0) > object2.Position.Y then print'Its colliding with this part' end |
|
|
| Report Abuse |
|
|
C_Sharper
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 6405 |
|
|
| 14 Sep 2016 11:44 AM |
pretend that vector3 addition isn't even there cx
|
|
|
| Report Abuse |
|
|
|
| 14 Sep 2016 11:44 AM |
| no because it needs to be in local space and you can just use GetTouchingParts instead |
|
|
| Report Abuse |
|
|
C_Sharper
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 6405 |
|
|
| 14 Sep 2016 11:45 AM |
Can't, that only works with parts that have cancollide turned off
Help? |
|
|
| Report Abuse |
|
|
C_Sharper
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 6405 |
|
| |
|
| |
|
C_Sharper
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 6405 |
|
|
| 14 Sep 2016 11:50 AM |
Test collision of a block in 3d space.
Can't use GetTouchingParts cause it only works with parts that have CanCollide on. |
|
|
| Report Abuse |
|
|
|
| 14 Sep 2016 11:52 AM |
GetTouchingParts using the collision geometry so you can only get box or spherical collisions unless you rescript |
|
|
| Report Abuse |
|
|
| |
|
|
| 14 Sep 2016 11:52 AM |
| uses the collision geometry** |
|
|
| Report Abuse |
|
|
C_Sharper
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 6405 |
|
|
| 14 Sep 2016 11:54 AM |
You guys aren't really helping, though I appreciate the replies.
I need to figure out how to customly compare and decide if the brick is touching on the Y axis this part
:/ |
|
|
| Report Abuse |
|
|
|
| 14 Sep 2016 11:55 AM |
1) cframe 2) corners 3) will not detect collision correctly, only box collisions |
|
|
| Report Abuse |
|
|
|
| 14 Sep 2016 11:57 AM |
Describe the problem that you need to solve more clearly. Do you need full, convex and concave 3D collision detection at arbitrary angles? Do you just need to check for the collisions of two sphers? Is it really just on 1 axis that you have to check?
Full 3D collision is a ridiculously complex subject, so try to boil down the problem.
|
|
|
| Report Abuse |
|
|
C_Sharper
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 6405 |
|
|
| 14 Sep 2016 11:57 AM |
This code needs to barely work, it's very simple what I'm trying to do. Don't need some advanced collision technique.
Can I have some example code? :l |
|
|
| Report Abuse |
|
|
C_Sharper
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 6405 |
|
|
| 14 Sep 2016 11:59 AM |
I just want to test the Y axis of my brick to see if it's higher up than another part.
But of course the size needs to be taken into account, but it doesn't work correctly if I add the entire Y axis size. |
|
|
| Report Abuse |
|
|
|
| 14 Sep 2016 11:59 AM |
I would love to help, but I still don't know what you're trying to do.
|
|
|
| Report Abuse |
|
|
|
| 14 Sep 2016 12:00 PM |
| the easiest way is to cast a ray at it and check the Dot Product |
|
|
| Report Abuse |
|
|
|
| 14 Sep 2016 12:01 PM |
Oh! Okay sorry you posted before me, didn't see it.
local function isTouchingY(a, b) if (math.abs(b.Position.Y-a.Position.Y) < a.Size.Y+b.Size.Y) then return true; end return false; end
|
|
|
| Report Abuse |
|
|
|
| 14 Sep 2016 12:01 PM |
Also be warned that that code only works if neither of the parts are rotated on the X or Z axes.
|
|
|
| Report Abuse |
|
|
|
| 14 Sep 2016 12:01 PM |
if (obj.CFrame+obj.CFrame.upVector*size.Magnitude).Y > --do same with -upvector then
end
thats not collision detection |
|
|
| Report Abuse |
|
|
C_Sharper
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 6405 |
|
| |
|
C_Sharper
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 6405 |
|
|
| 14 Sep 2016 12:54 PM |
@mike
That's a problem cause the pins will fall over and stuff, so doing this would be a pin-fallen detector thing.
Also I couldn't get your algorithm working Fluffy.
:L
|
|
|
| Report Abuse |
|
|
|
| 14 Sep 2016 12:57 PM |
Explain the actual issue and maybe we can work out a different solution. What are those pins?
|
|
|
| Report Abuse |
|
|
C_Sharper
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 6405 |
|
|
| 14 Sep 2016 01:03 PM |
Ok let me reword this completely. Hopefully we can get somewhere.
I'm making a pinsetter (for a bowling game) and I want the best pin-still-standing method available. There could be actually a better method than this, but this would definitely work every time. Like, the method to determine what pins have fallen? That's what I'm trying to figure out. I want this method to work like 99% of the time. What I was trying to do was test if the pins were touching the pinsetter when it came down to pick them up. And if they were, it picked em' up, otherwise they just let them sit on the wood and get swept into the pit, if that makes sense.
|
|
|
| Report Abuse |
|
|
|
| 14 Sep 2016 01:28 PM |
| Perfect! I know what you need, and it's not collision. Check the angle between the up vector of the pins and the 'global' up, (0, 1, 0). See if the angle between them is less than some tolerance. local function ############### return (pin.CFrame.upVector:Dot(Vector3.new(0, 1, 0)) > 0.95) end That will return true if the top of the ### ## facing upwards, within a certain tolerance. Make the 0.95 closer to 1 to decrease the tolerance, and change the axis to (1, 0, 0) or (0, 0, 1) if your pins have a difference face aimed upwards. Also I kinda lied - the dot product of those vectors is actually the ###### of the angle. Making the function based on a tolerance angle would be slower, but look like this: local function ############### return ########################################################## 1, 0)))) < 10) end That's a tolerance of 10 degrees. |
|
|
| Report Abuse |
|
|