|
| 02 May 2014 03:13 PM |
This is what my bullet holes look like when "created"
puu.sh/8wtU1.png
I simply CFrame the parts on the hit location, then I use: "getSurfaceFromHit(hit,position)"
to place the bullet hole decal on the right surface.
However, when I do it this way, when you view the bullet holes from different angles you can notice they hover a bit from surfaces. How would I kind of like, place them smoothly on surfaces depending on the surface? |
|
|
| Report Abuse |
|
|
stravant
|
  |
 |
| Joined: 22 Oct 2007 |
| Total Posts: 2893 |
|
|
| 02 May 2014 03:19 PM |
What does "getSurfaceFromHit(hit,position)" return?
If it returns a normal vector, then you can do something like:
part.CFrame = part.CFrame - surfaceNormal*0.49, or whatever. |
|
|
| Report Abuse |
|
|
|
| 02 May 2014 03:21 PM |
| StealthKing95: Requests for assistance belong elsewhere, friend. |
|
|
| Report Abuse |
|
|
|
| 02 May 2014 04:24 PM |
@stravant
It simply returns a face enum for the decal
@ UndefinedEntity
I know, however at Scripting Helpers the issue seemed to be too "complex" |
|
|
| Report Abuse |
|
|
|
| 02 May 2014 04:26 PM |
This is the function(not my creation)
function eng.getSurfaceFromHit(part,pos) pos = part.CFrame:inverse() * pos * 2 / part.Size if pos.x < -.999 then return Enum.NormalId.Left elseif pos.x > .999 then return Enum.NormalId.Right elseif pos.y < -.999 then return Enum.NormalId.Bottom elseif pos.y > .999 then return Enum.NormalId.Top elseif pos.z < -.999 then return Enum.NormalId.Front elseif pos.z > .999 then return Enum.NormalId.Back end end |
|
|
| Report Abuse |
|
|
oseday
|
  |
| Joined: 27 Aug 2008 |
| Total Posts: 1308 |
|
|
| 02 May 2014 05:17 PM |
ray,hit,pos = rayblabla() norm = getSurfaceFromHit(hit,position) effect.FormFactor = "Custom" --important effect.Size = Vector3.new(x,y,0.2) effect.CFrame = CFrame.new(pos,norm+pos)*CFrame.new(0,0,0.19)
try this? |
|
|
| Report Abuse |
|
|
stravant
|
  |
 |
| Joined: 22 Oct 2007 |
| Total Posts: 2893 |
|
|
| 02 May 2014 05:21 PM |
That won't work because norm isn't a vector. You can convert it like this:
norm = hit.CFrame:vectorToWorldSpace(Vector3.FromNormalId(getSurfaceFromHit(hit,position))) |
|
|
| Report Abuse |
|
|
oseday
|
  |
| Joined: 27 Aug 2008 |
| Total Posts: 1308 |
|
|
| 02 May 2014 05:40 PM |
| I didn't see that it wasn't a normal... |
|
|
| Report Abuse |
|
|
|
| 02 May 2014 09:44 PM |
"effect.Size = Vector3.new(x,y,0.2)"
x and y? |
|
|
| Report Abuse |
|
|
|
| 02 May 2014 09:47 PM |
btw
local norm = hit.CFrame:vectorToWorldSpace(Vector3.FromNormalId(surf)) --fx.CFrame = CFrame.new(position, position + hit.CFrame.lookVector) fx.CFrame = CFrame.new(pos,norm+pos)*CFrame.new(0,0,0.19)
05:46:46.798 - Workspace.Player1.Gun.Main:115: bad argument #2 to '?' (Vector3 expected, got nil) |
|
|
| Report Abuse |
|
|
|
| 02 May 2014 09:48 PM |
nvm im really tired and it was my own mistake.
However the bullet holes go inside walls |
|
|
| Report Abuse |
|
|
| |
|
zars15
|
  |
| Joined: 10 Nov 2008 |
| Total Posts: 9999 |
|
|
| 03 May 2014 03:20 PM |
| Oh shush, trying to figure out right formulas for CFrame is such an entertaining process! |
|
|
| Report Abuse |
|
|
|
| 03 May 2014 03:26 PM |
| CFrame and Vector3s are the only things in roblox lua that give me a hard time. Probably because of my crappy grade in geometry |
|
|
| Report Abuse |
|
|
oseday
|
  |
| Joined: 27 Aug 2008 |
| Total Posts: 1308 |
|
|
| 03 May 2014 03:33 PM |
ray,hit,pos=rayblabla() norm=hit.CFrame:vectorToWorldSpace(Vector3.FromNormalId(getSurfaceFromHit(hit,pos))) effect.CFrame = CFrame.new(pos,norm+pos)*CFrame.new(0,0,effect.Size.Z+0.01)
This must work. Don't change other things. |
|
|
| Report Abuse |
|
|
|
| 03 May 2014 04:27 PM |
Even with that exact code, the bullet "holes" seem to be inside walls,
video proof youtube.com/watch?v=E6pDJub90xc |
|
|
| Report Abuse |
|
|
oseday
|
  |
| Joined: 27 Aug 2008 |
| Total Posts: 1308 |
|
|
| 03 May 2014 08:19 PM |
effect.Size.Z+0.01 change this to effect.Size.Z-0.01 |
|
|
| Report Abuse |
|
|
|
| 04 May 2014 06:11 AM |
| I already tried that with the same results :/ |
|
|
| Report Abuse |
|
|
oseday
|
  |
| Joined: 27 Aug 2008 |
| Total Posts: 1308 |
|
|
| 04 May 2014 09:34 AM |
| May I have your script and test myself? |
|
|
| Report Abuse |
|
|
| |
|
oseday
|
  |
| Joined: 27 Aug 2008 |
| Total Posts: 1308 |
|
|
| 04 May 2014 02:39 PM |
I found the problem. I forgot to divide the Z size by 2. Change that to: part.Size.Z/2-0.01 and you'll be fine. |
|
|
| Report Abuse |
|
|