|
| 06 Aug 2011 05:29 PM |
Okay, so I have some functions that are called:
function translate(partA, partB, change) print("Hello2") if partA:IsA("BasePart") and partB:IsA("BasePart") then partA.CFrame = partB.CFrame:toWorldSpace((partB.CFrame * change):toObjectSpace(partA.CFrame)) end end
function slowRotate(partA, partB, rotVec, time) x, y, z = rotVec.x, rotVec.y, rotVec.z frames = 30*time print(frames) if time ~= 0 then x, y, z = x/frames, y/frames, z/frames end for i = 1, frames do print("Hello1") translate(partA, partB, CFrame.Angles(x, y, z)) wait(time/frames) end end
and when I run it, I get the output:
... 30 Hello1 30 Hello1 30 Hello1 Transformed!
(Transformed is the output I have for when all the methods are *supposed* to be finished)
As you can see from the code, I have several markers for when the code is executed. "Hello1" tells me it at least got into the loop with for i=1 and whatnot. "30" tells me how many frames I am going to run the code for. "Hello2" tells me that the next method is called.
But, for some stupid reason, as the output shows, the code prints "Hello1", which is right before calling the 'translate' method, and never, ever, prints "Hello2". But it continues on to print the "Transformed!" at the end, which tells me there isn't a syntax error anywhere.
If it makes any difference, slowTranslate is called from a coroutine, which runs along side about 40? other coroutines that run the same methods.
Can one help me figure this out? |
|
|
| Report Abuse |
|
|
|
| 06 Aug 2011 06:04 PM |
I actually wait until my post dies from the front page, unlike you people who will bump if theirs isn't the first post in the list.
Will anyone help me? |
|
|
| Report Abuse |
|
|
|
| 06 Aug 2011 07:37 PM |
| Wow, hardly any more views. Thanks, guys, for bothering to read my topic. |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 06 Aug 2011 07:45 PM |
Whenever you recursively go back to the function you forgot to include time
translate(partA, partB, CFrame.Angles(x, y, z),time)
|
|
|
| Report Abuse |
|
|
|
| 06 Aug 2011 07:50 PM |
| I don't know what the heck you are talking about recusion for, and the translate method doesn't take the time parameter. |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 06 Aug 2011 07:52 PM |
| sorry I was scimming through it and just thought you were recursively looping. |
|
|
| Report Abuse |
|
|
| |
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 06 Aug 2011 08:44 PM |
| Can I see how you're calling it? |
|
|
| Report Abuse |
|
|
|
| 06 Aug 2011 08:46 PM |
rotate({rthigh, rcalf}, rfoot.FootHinge, Vector3.new(math.rad(-90), 0, 0), 1) rotate({lthigh, lcalf}, lfoot.FootHinge, Vector3.new(math.rad(-90), 0, 0), 1)
which goes to:
function rotate(models, part, rotVec, time) for _,m in pairs(models) do for _,p in pairs(m:GetChildren()) do coroutine.resume(coroutine.create(slowRotate), p, part, rotVec, time) end end end
which goes to the abovementioned functions. |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 06 Aug 2011 08:57 PM |
| well since you aren't using local, maybe it's confusing some of the variables like x,y and z? Just a guess. |
|
|
| Report Abuse |
|
|
|
| 06 Aug 2011 09:01 PM |
| But the problem is, the loop just....stops before it calls the translate method. |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 06 Aug 2011 09:03 PM |
| It could be coroutines being a b**** and not letting you call another function inside so just combine them. |
|
|
| Report Abuse |
|
|
|
| 06 Aug 2011 09:05 PM |
| You know what, that might be it..... *rageface*. |
|
|
| Report Abuse |
|
|
|
| 06 Aug 2011 09:08 PM |
Yeah, that was it. Thank you very much. One thing I discovered: having numerous coroutines is not the best idea if you want a lag-free game. |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
|
| 06 Aug 2011 09:09 PM |
| Neither is realistic cars. Kinda takes the fun out of things doesn't it? |
|
|
| Report Abuse |
|
|
|
| 06 Aug 2011 09:10 PM |
:-/ Looks like I'll have to edit welds and unanchor everything rather than have the entire thing CFramed.
Thanks again. |
|
|
| Report Abuse |
|
|
SDuke524
|
  |
| Joined: 29 Jul 2008 |
| Total Posts: 6267 |
|
| |
|