|
| 27 Jul 2011 04:18 PM |
| I have a model that I want to arrange multiple of in a circle around a center brick. Is there any function or the likes that would be more efficient than CFraming it by hand? |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2011 04:29 PM |
Yes, there is.
local CenterPt = Vector3.new(0,0,0) local radius = 10 local models = { Workspace.Model1, Workspace.Model2, } local numModels = #models local i = 0 local PositionC = coroutine.create(function(model) model:MoveTo(Vector3.new(math.cos(i*(2*math.pi/numModels))*radius*math.pi, 0, math.sin(i*(2*math.pi/numModels))*radius*math.pi) + CenterPt) i = i + 1 end)
for _, v in pairs(models) do coroutine.resume(PositionC, v) end
Try that. It MIGHT not work as desired... My math may be a bit off. |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2011 04:30 PM |
| I'm pretty sure you're an alt :P |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2011 04:36 PM |
| @RBX, how far apart does it make the models? |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2011 04:45 PM |
| Output is saying "Script "Workspace.Script" Line 4" and then "Stack end" |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2011 04:49 PM |
| Tag your models that need to be arranged in a circle. |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2011 04:58 PM |
| I added another end to see if that would solve and it said "'eof expected near "end" |
|
|
| Report Abuse |
|
|
| |
|
killjoy37
|
  |
| Joined: 27 Aug 2008 |
| Total Posts: 2821 |
|
|
| 27 Jul 2011 05:08 PM |
Instead of
local models = { Workspace.Model1, Workspace.Model2, }
Try
local models = {Workspace.Model1, Workspace.Model2, Workspace.Model3}
|
|
|
| Report Abuse |
|
|
|
| 27 Jul 2011 05:29 PM |
| It says it's running, but it's not doing anything. |
|
|
| Report Abuse |
|
|
| |
|
|
| 27 Jul 2011 06:46 PM |
What exactly is happening? Try adding some print lines to pinpoint the location of the error.
@citymaster
What makes you say that? |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2011 06:50 PM |
With one print after each line with the number of the line above, output reads:
1 2 3 4 5 9 10 6 7 8 11 10 11 10 11 10 11 10 11 10 11 10 11 10 11 10 11 10 11 10 11 10 11 10 11 10 11 10 11 10 11 |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2011 07:05 PM |
DUH... Forgot to make the coroutine loop infinitely... The coroutine 'dies' when we previously resumed it since there was no loop. After a coroutine dies, it cannot be resumed again. If we have a continuous loop, we should be fine. We also have to change the code around a little bit because of this loop.
local CenterPt = Vector3.new(0,0,0) local radius = 10 local models = { Workspace.Model1, Workspace.Model2, } local numModels = #models local i = 1 local PositionC = coroutine.create(function(Models) while true do local model = Models[i] model:MoveTo(Vector3.new(math.cos(i*(2*math.pi/numModels))*radius*math.pi, 0, math.sin(i*(2*math.pi/numModels))*radius*math.pi) + CenterPt) i = i + 1 coroutine.yield() end end)
for _, v in pairs(models) do coroutine.resume(PositionC, models) end
|
|
|
| Report Abuse |
|
|
|
| 27 Jul 2011 07:10 PM |
Still not working :\
1 2 3 4 5 13 14 6 7 8 9 10 15 14 11 7 8 9 10 15 14 11 7 8 9 10 15 14 11 7 8 9 10 15 14 11 7 8 9 10 15 14 11 7 8 9 10 15 14 11 7 8 9 10 15 14 11 7 8 9 10 15 14 11 7 8 9 10 15 14 11 7 8 9 10 15 14 11 7 8 9 10 15 14 11 7 8 9 10 15 14 11 7 8 9 10 15 14 11 7 8 9 10 15 14 11 7 8 9 10 15 14 11 7 8 9 10 15 |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2011 07:12 PM |
It's going through every model... Is there space for the model in these locations around the center point? Try looking above your desired center point.
The math, of course, may also be wrong. |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2011 07:14 PM |
| I just tested it with 6 models. It puts the models in a circle around the center point (at congruent angles from each other, as planned). I'm not sure why it isn't working for you. |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2011 07:15 PM |
| I have tried changing the location of the center brick |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2011 07:16 PM |
| Wait, found the problem. I put the models in the Lighting *durp* |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2011 07:17 PM |
| Can you post your version of the script, then? |
|
|
| Report Abuse |
|
|
|
| 27 Jul 2011 07:18 PM |
Ah, late post. Glad you found the problem. ^_^ |
|
|
| Report Abuse |
|
|