darthpyro
|
  |
| Joined: 18 Aug 2009 |
| Total Posts: 3569 |
|
|
| 27 Feb 2016 08:18 AM |
Is there a maximum amount of repetitions (without waits) before crashes occur? Is there a general guideline or a way to calculate said number?
e.g.
for i = 1, math.ceil(factor / 30) do position = position + (velocity / factor) velocity = velocity + Vector3.new(0, gravity / factor, 0) local hit, hitPosition = game.Workspace:FindPartOnRayWithIgnoreList(Ray.new(position, velocity / factor), ignoreList)
if funct then funct(hitPosition, position) end if hit then return hit, hitPosition end end
wait()
This can cause crashes, but I would prefer not to wait every time I run the loop. |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 27 Feb 2016 08:25 AM |
That will never cause a crash.
while true do end
Doesn't cause a crash.
|
|
|
| Report Abuse |
|
|
|
| 27 Feb 2016 08:27 AM |
I'm not sure, it could depend on what is being looped. If you really want to know, perhaps guess and test?...
I'm not sure why you would want to though. What are you trying to accomplish? |
|
|
| Report Abuse |
|
|
darthpyro
|
  |
| Joined: 18 Aug 2009 |
| Total Posts: 3569 |
|
|
| 27 Feb 2016 08:28 AM |
I'm performing raycasting and calling passed functions hundreds or thousands of times a second. This causes ROBLOX to crash.
If you don't think this is the issue, I would welcome you to find the issue: http://www.roblox.com/games/33516870/Gravity-Raycasting |
|
|
| Report Abuse |
|
|
|
| 27 Feb 2016 08:38 AM |
| So you are trying to finish the loop all in the same instant? |
|
|
| Report Abuse |
|
|
darthpyro
|
  |
| Joined: 18 Aug 2009 |
| Total Posts: 3569 |
|
|
| 27 Feb 2016 08:42 AM |
This script simulates raycasting with a gravity force acting upon it. As it stands, it seems casting a ray is a intensive enought that you can see animation in a part following the ray if you cast the ray multiple times between waiting. However, doing this for too long without waiting will cause ROBLOX to crash.
I'm not really sure how to improve the performance of this, short of scrapping the inner for loop and just letting the ray be inaccurate. |
|
|
| Report Abuse |
|
|
darthpyro
|
  |
| Joined: 18 Aug 2009 |
| Total Posts: 3569 |
|
|
| 27 Feb 2016 09:01 AM |
| Is there some way to find the source of a crash? |
|
|
| Report Abuse |
|
|
darthpyro
|
  |
| Joined: 18 Aug 2009 |
| Total Posts: 3569 |
|
|
| 27 Feb 2016 09:11 AM |
I have concluded that the issue is drawing the tracers at the locations of the rays. Is this an inherent problem with creating tons of parts, or is there a way to make this more efficient?
Right now I'm calling this:
module.visualizeRay = function(startPoint, endPoint) local dist = (endPoint - startPoint).magnitude local brick = Instance.new("Part", game.Workspace) brick.Anchored = true brick.CanCollide = false brick.Size = Vector3.new(0.2, 0.2, dist) brick.CFrame = CFrame.new(startPoint, endPoint) * CFrame.new(0, 0, dist) brick.Parent = module.getContainer() return brick end |
|
|
| Report Abuse |
|
|