Lagging Spheres

Added by Connor Huffine 10 months ago

This may just be an innefficient wway to have written this code, but these spheres lag terribly when viewed by multiple clients. The button model can easily be replaced with a primitve. Basically, this script creates 100 spheres over a cone and demonstrates networked objects, but the problem is that it doesn't work nicely at all.

@ <Script Name="box" Language="Lua">function main(obj, args)

--Spawns 100 balls
i = 0 a = 0 b = 0 c = 0
while(i &lt; 100) do
p = primitive()
p.size = vector3(1,1,1)
a = math.random(-3,3)
b = math.random(30,500)
c = math.random(67,73)
p.position = vector3(a,b,c)
p.type = primitivetype.sphere
p.physics.enabled = true
p.physics.movable = true
p.physics.weight = 20
p.network.enabled = true
p.complexity = verylow
scene:add(p)
i = i+1
end
end
&lt;/Script&gt;
&lt;Model Name="box1" Size="0.2,0.05316806,0.2" Position="-0.1,1,18" Source="\\linwall\VastPark\Server\Models\Button.model"&gt;
&lt;MaterialGroup Id="-1"&gt;
&lt;Material Ambient="#8e3535" Diffuse="#810a0a" Emissive="#000000" Specular="#000000" Power="50" EnableTextures="True" /&gt;
&lt;/MaterialGroup&gt;
&lt;Physics Enabled="False" Movable="False" /&gt;
&lt;Trigger Name="box-Trigger" Event="MouseClick" Target="box" Enabled="True" /&gt;
&lt;Trigger Name="Box-Over" Event="MouseEnter" Target="Box-MouseEnter" Enabled="True" /&gt;
&lt;Trigger Name="Box-off" Event="MouseLeave" Target="Box-MouseLeave" Enabled="True" /&gt;
&lt;/Model&gt;
&lt;Script Name="Box-MouseEnter" Language="Lua"&gt;function main(obj, args)
obj.material.emissive = rgb('#00FF00')
end&lt;/Script&gt;
&lt;Script Name="Box-MouseLeave" Language="Lua"&gt;function main(obj, args)
obj.material.emissive = rgb('#000000')
end&lt;/Script&gt;
&lt;Primitive Name="cone" Type="Cone" Complexity="VeryLow" Size="20,20,20" Position="0,0,70"&gt;
&lt;MaterialGroup Id="-1"&gt;
&lt;Material Ambient="#4c4c4c" Diffuse="#cccccc" Emissive="#000000" Specular="#000000" EnableTextures="True" /&gt;
&lt;/MaterialGroup&gt;
&lt;Physics Enabled="True" Movable="False" Weight="20" /&gt;
&lt;/Primitive&gt;

@


Replies (1)

RE: Lagging Spheres - Added by Praveen Wickramasinghe 10 months ago

Hey Connor,
The world lags because of the networked physics the spawn-balls have. Network physics aren’t at its best at the moment. One workaround we can suggest is to send a custom message to the server and ask the server to broadcast a message to all clients to spawn not-networked balls in every client’s world.

Client-side code to send message to the server

Server-side code to broadcast a message

Client-side code to Start Spawn on message Received

c.png (26.1 kB)

a.gif (4.7 kB)

b.gif (9.3 kB)

c.gif (13.6 kB)

a.png (7 kB)

b.png (15.7 kB)

(1-1/1)