generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Bullet effects

Previous Thread :: Next Thread 
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
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 is not online. stravant
Forum Moderator
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
UndefinedEntity is not online. UndefinedEntity
Joined: 12 Apr 2014
Total Posts: 9
02 May 2014 03:21 PM
StealthKing95: Requests for assistance belong elsewhere, friend.
Report Abuse
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
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
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
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 is not online. 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 is not online. stravant
Forum Moderator
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 is not online. 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
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
02 May 2014 09:44 PM
"effect.Size = Vector3.new(x,y,0.2)"

x and y?
Report Abuse
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
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
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
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
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
03 May 2014 02:35 PM
Really frustrating
Report Abuse
zars15 is not online. 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
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
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 is not online. 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
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
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 is not online. 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
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
04 May 2014 06:11 AM
I already tried that with the same results :/
Report Abuse
oseday is not online. oseday
Joined: 27 Aug 2008
Total Posts: 1308
04 May 2014 09:34 AM
May I have your script and test myself?
Report Abuse
StealthKing95 is not online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
04 May 2014 10:18 AM
pastebin/1eFVJxCJ
Report Abuse
oseday is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image