Best way to go about making a "prop grid" and placing props on it
3 replies, posted
So basically I need to figure out how to go about making a grid of points on a flat map and then placing rectangular/square props (namely phx) exclusively on and in line with that grid. If that makes zero sense once soever, imagine how legos work:
https://files.facepunch.com/forum/upload/109874/1fc83b1a-0f5d-4b03-9f68-f302a5f94931/image.png
Pretend those legos are phx props and the studs are points (more or less). They can only go at 90 degree angles to the studs and only be placed exactly on said studs.
I'm not asking for someone to write this for me as I'm plenty okay with lua as it is, just rather to pitch some ideas about ways to go about doing it because quite frankly i'm stumped.
you didnt describe your end goal though, what's the expected input and what's the desired output?
Well basically I'm trying to figure out how to recreate the first 20 seconds or so of this:
https://www.youtube.com/watch?v=oDVAjvNeGA8
Ignore the copying blocks bit, just focus on the way blocks are placed. I've already got an entity set up for generating a block with whatever stud size you throw at it (assuming there's a phx prop that correlates), now I'm just trying to mentally comprehend how to get blocks to snap to a grid for spawning and initial orientation purposes.
I know I'm being vague here but I'm having a hard time putting into words what it is. The best way I can describe it is literally the first 20 seconds of that video.
As far as determining the Z position goes, the method I describe should work (again assuming you dont want to be able to fill potential holes, solving the hole problem is another thing)
In addition to that you're going to want to snap the new prop's position to the base's min vector + its offset, its as easy as:
newProp:SetAngles(baseProp:GetAngles())
newProp:RotateAngle depending on if you want to rotate it 90 degrees (forgot the actual function name, look it up on the wiki)
newProp:setMinPositionTo(baseProp's min position + Vector(x offset, y offset, Z)) where Z is calculated using the method described above, where x offset and y offset are integers to be multiplied by the 'phx unit' which is the distance of a single phx square
There's no such function as setMinPosition, you should implement it like so:
ent:setMinPosition(pos)
diff= ent:GetPos() - ent's min Vec
ent:SetPos(pos + diff)
I might have some mistakes but that's the gist of it
Sorry, you need to Log In to post a reply to this thread.