|
| 25 Jul 2016 11:50 PM |
I thought once I had the two arrays sorted out, the magic was gonna happen, but alas 'Shakara when the walls fell'
I had this working using setCells but understand WriteVoxel is the new way(?) and tried to revamp it to work that way.
try and not to be too harsh, as I have no clue what I'm doin...
[code] --bouncing ball-o-death
local ball = script.Parent local bf = script.Parent.BodyForce local debounce = false local forceMedian = 10 ball.Touched:connect(function(other) if other then if not (other.Name == ("Terrain")) then return end if debounce then return end debounce = true local loc = other:WorldToCell(ball.Position-Vector3.new(0,0.5,0)) local region = Region3.new(Vector3.new(loc.X-1, loc.Y-1, loc.Z-1), Vector3.new(loc.X+1, loc.Y+1, loc.Z+1)) region = region:ExpandToGrid(4) local mat, occ = other:ReadVoxels(region, 4) local size = occ.Size for i = 1,size.X do for j = 1, size.Y do for k = 1, size.Z do occ[i][j][k] = 0 end end end other:WriteVoxels(region, 4, mat, occ) local hoverForce = ball:GetMass()*9.62 bf.Force = Vector3.new (math.random(-forceMedian*2,forceMedian*2),math.random(forceMedian*8,forceMedian*16)+hoverForce,math.random(-forceMedian*2,forceMedian*2)) wait(math.random(3,5)/10) bf.Force = Vector3.new (0,hoverForce*0.8,0) debounce = false end end) [/code]
sorry, also dunno how to add code to a post |
|
|
| Report Abuse |
|
|
|
| 26 Jul 2016 02:01 AM |
Well, surprise! the code worked! (I think)
maybe for
local loc = other:WorldToCell(ball.Position-Vector3.new(0,0.5,0)) -- I meant PreferSolid?
should the mat's be enum'd to air?
am I losing focus on occ?
man... I really wish I knew what I was doin!
|
|
|
| Report Abuse |
|
|
|
| 26 Jul 2016 12:16 PM |
Still no joy... Doesn't seem to be problem with the mat's or the occ's or the focus of occ...
I've run out of things to try, someone point me in the right direction!!! please :P |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2016 12:02 AM |
tried the prefersolid and preferempty removed and fiddled with the fudge factor in the ball's position, fiddled with the size of the region...
I know its something simple and I'm just not seeing it... sigh.... |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2016 01:16 AM |
still totally blind to the answer to this...
wish I could use my head for something other than a place to hang my hair... |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2016 03:30 AM |
I don't get it, the mat's change, the occ's change but the map don't change. Stumped stumped I am Stumped!
I'm even pretty sure if the ball hits near the same spot again, the mat's and occ's are both air/0 but the map continues to look the same. |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2016 02:33 PM |
| Well... I have noticed an effect on the terrain, just not near where it starts... Not sure what is going on here, but the ball has certainly contacted the surface much more than the few holes I can find searching the map extensively. I'm not understanding why the holes only appear in the few spots they do (even making tunnels of sorts (I think)) maybe I should start anew... |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2016 02:34 PM |
I read the post one and a half times, and then the title three, before I understood it as "WriteVoxels" instead of "WriteVowels".
|
|
|
| Report Abuse |
|
|
|
| 28 Jul 2016 02:24 PM |
Well I did simplify things to figure it out, I was stupidly using a prototyping map to play around with things, and it was a big map and I was off to one side and didn't notice that indeed I was making craters, just not where I had expected... sigh...
Once I made the map simple again without all the other stuff around I was playin with, and a much smaller map, it was obvious that MY loc variable was being divided by 4, so the fix was simple... I knew it was something simple!
[code] --bouncing CraterMaker
--startinig variables sorry about the horrid cryptic variable names just a prototype local ball = script.Parent local bf = ball.BodyForce local fM = 20 local db = false local si = 3 local hF = ball:GetMass()*9.62
ball.Touched:connect(function(other) print(ball.Velocity.Magnitude)--just a prelim to making the diameter depend on speed if other.Name ~= "Terrain" then return end --has to be a terrain to writevoxels if db then return end --if you hadn't guessed db is for debounce db = true --see above ;p local loc = other:WorldToCell(ball.Position) --where's the ball and normal the pos loc=loc*4 --THIS IS WHERE I WENT WRONG, not sure why this is needed but for me it is si = math.random(1,4) --for now random diameter, eventually i was thinkin it should depend on speed local region = Region3.new(Vector3.new(loc.X-si, loc.Y-si, loc.Z-si), Vector3.new(loc.X+si, loc.Y+si, loc.Z+si)) --^^^ setting up the region to change region = region:ExpandToGrid(4) --another normal local mat, occ = other:ReadVoxels(region, 4) --getting the material and occupancy for i = 1, occ.Size.X do for j = 1, occ.Size.Y do for k = 1, occ.Size.Z do occ[i][j][k]=0 --setting all the occupancy to 0 end end end other:WriteVoxels(region, 4, mat, occ) --finally write the voxels using the mats and occs bf.Force = Vector3.new(math.random(-fM*2,fM*2), math.random(fM*5, fM*10), math.random(-fM*2, fM*2)) --^^^ a big dumb random gen to throw the ball around (without really throwing the ball around) wait(math.random(2,4)/10) --random time interval to launch the ball (umm FORCE the ball to move heh) bf.Force = Vector3.new(0,hF*0.8,0) --lower the effect of gravity to slow the balls fall db=false --done with debounce.. ready for next terrain hit! end) [/code] |
|
|
| Report Abuse |
|
|