|
| 27 May 2015 10:34 AM |
local impact = i:Clone() impact.Parent = workspace local pos = Mouse.Hit.p - Mouse.Target.Position impact.CFrame = Mouse.Target.CFrame + (pos - (Vector3.new(pos.X, 0, pos.Z).unit)) impact.Decal.Face = Mouse.TargetSurface impact.Anchored = true
I can't seem to get it to kind of go inside a part so that not half of the Impact Part is sticking out, but only like .1, (it's like 1 Stud in all Axises) cos if it's half sticking out then if I shoot something from the side it will look unrealistic the way the Decal would be on the side of the part :/ any help plz?
here is the one that works best right now (cos the one above sometimes spawns them inside a part and usually spawns them to the left of the mouse) and it's the one that makes .5 pop out... local impact = Impact:Clone() impact.Parent = workspace local pos = Mouse.Hit.p - Mouse.Target.Position impact.CFrame = Mouse.Target.CFrame + (pos) impact.Decal.Face = Mouse.TargetSurface impact.Anchored = true
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 10:35 AM |
I actually recommend attaching a ParticeEmitter.
-𝒩 | Anticodist, Scripter |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 10:43 AM |
it will just keep spawning the Effect :/ well I might try but I'm not sure if it would work :/
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 10:50 AM |
Rig it so the particles blast backwards. I think it would look really cool.
-𝒩 | Anticodist, Scripter |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 10:58 AM |
nah, I think that would make it crappy (in terms of realism) :/ plus, I tried ParticleEmitter just there, and well, the results are crap... I set the rate to 1 and Lifetime to math.huge/inf and so when I clone the Impact Part I wait 3 Seconds and it doesn't even make 1 Particle yet! strange :/
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 11:03 AM |
I tried a few other tricks with ParticleEmitter and now, I see it's even crappier :/ seriously... plz someone gotta know something -_-
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 11:03 AM |
Oh no, no, no! I mean make the initial hit a particle for like the shortest time. Like the wall bits are flying off. Then do whatever you had planned. I was suggesting an effect :)
-𝒩 | Anticodist, Scripter |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 11:09 AM |
oh no, I meant IMPACT not Effect XD Effects are easy to do XD
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 11:09 AM |
I was so confused. I was like o_O
-𝒩 | Anticodist, Scripter |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 11:11 AM |
lol XD
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 11:43 AM |
anyone?
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 11:50 AM |
I not sure what you want, but I think you want this.
impact.CFrame = Mouse.Hit * CFrame.new(0.4,0,0) |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 11:53 AM |
or maybe you need this function (made this a while ago)
function DetermineSurfaceNormal(Part,Pos) local RelativeObjectSpace = Part.CFrame:pointToObjectSpace(Pos)/Part.Size local AbsoluteObjectSpace = Vector3.new(math.abs(RelativeObjectSpace.x),math.abs(RelativeObjectSpace.y),math.abs(RelativeObjectSpace.z)) local LargestVector if AbsoluteObjectSpace.x > AbsoluteObjectSpace.y and AbsoluteObjectSpace.x > AbsoluteObjectSpace.z then LargestVector = Vector3.new(RelativeObjectSpace.x,0,0).unit elseif AbsoluteObjectSpace.y > AbsoluteObjectSpace.z then LargestVector = Vector3.new(0,RelativeObjectSpace.y,0).unit else LargestVector = Vector3.new(0,0,RelativeObjectSpace.z).unit end return (Part.CFrame-Part.Position):pointToWorldSpace(LargestVector) end
|
|
|
| Report Abuse |
|
|
|
| 27 May 2015 11:59 AM |
wow thnx steven :D em, would ya mind telling me plz, what this does? I never used pointToObjectSpace, pointToWorldSpace and stuff, and I needa know what the rest is XD Thnx :)
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 12:59 PM |
sadly it doesn't work :/ (if pos should have been Mouse.Hit.p, and for positioning either use the position returned or the position return + part.CFrame)
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 02:05 PM |
| So. If I'm not mistaken you have the part you hit and what position it hit the part, and you want to take that position and sink it in the hit surface by .4, right? |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 02:20 PM |
1. Make Ray. 2. Call ur function(Hit, Pos) --Hit and Pos are from FindPartOnRay(). 3. Random Position.
so what I wanna do is, insert my Impact Part into the Part on the Position where the Ray hit it, and then insert the Part into it so it doesn't stick out, it's 1 Stud in all Axises, so I'd like most of it inside the Part that was hit... I think I did something good when messing around with my own code when waiting for ur reply, and well, I have a long part, well the Axises on which the part was longest, the Impact was VERY well fit in, but of course on the thin side, it kind of still stuck out :/ 32, 12, 2 is the size of that part... so I'll need to see what I can do to make the Impact evenly be insert by the same amount into the target if ya know what I mean... sry for such long posts and no sense, just in a hurry...
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 02:28 PM |
-- this function only works for blocks. no wedges, spheres, unions etc... function DetermineSurfaceNormal(Part,Pos) local RelativeObjectSpace = Part.CFrame:pointToObjectSpace(Pos)/Part.Size local AbsoluteObjectSpace = Vector3.new(math.abs(RelativeObjectSpace.x),math.abs(RelativeObjectSpace.y),math.abs(RelativeObjectSpace.z)) local LargestVector if AbsoluteObjectSpace.x > AbsoluteObjectSpace.y and AbsoluteObjectSpace.x > AbsoluteObjectSpace.z then LargestVector = Vector3.new(RelativeObjectSpace.x,0,0).unit elseif AbsoluteObjectSpace.y > AbsoluteObjectSpace.z then LargestVector = Vector3.new(0,RelativeObjectSpace.y,0).unit else LargestVector = Vector3.new(0,0,RelativeObjectSpace.z).unit end return (Part.CFrame-Part.Position):pointToWorldSpace(LargestVector) end
-- hitPart = Part, hitPos = Vector3, depth = Number function getInpactCFrame(hitPart, hitPos, depth) local hitNormal = DetermineSurfaceNormal(hitPart, hitPos) return CFrame.new(hitPos - hitNormal*depth, hitPos) end
( I haven't tested this at all ) |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 02:33 PM |
thnx, I'll test it later :)
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 02:44 PM |
wow! finally works like a charm! :D even with small pieces! :D btw, could u plz tell me what was wrong with my latest code?
local dir = (Mouse.Target.Position - Mouse.Hit.p).unit impact.CFrame = CFrame.new(Mouse.Hit.p) + (dir / 2)
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 02:56 PM |
What my snippet does is taking the vector looking away for the hit surface and using that to get the proper direction and position.
your code just extends the shot a bit. that works fine if you shoot a part at an absolute right angle but it doesn't when you shoot a part from the side.
right angle: fine |_ |
any other angle: wrong
| |\
(Sorry if I explained that badly) |
|
|
| Report Abuse |
|
|
|
| 27 May 2015 02:58 PM |
I understood :) but what I meant about my code was, I wanna know why it only sank the part in by the amount I wanted ONLY when the certain Axises that was hit of the part is like 10 Studs or more... cos from what I know, it should work :/
"My Life is going Good... but..." |
|
|
| Report Abuse |
|
|