extensions/urho3d: Add nodes and components in LOCAL mode by default
This commit is contained in:
parent
d7a6737569
commit
f089913ea6
@ -142,7 +142,9 @@ Note:
|
||||
otherwise augment your nodes in such a way that you can generate or set
|
||||
resources to each node that requires it.
|
||||
|
||||
Make sure to add the client-side components to the node using urho3d.LOCAL.
|
||||
The sandbox wrapper adds the client-side components to the node using
|
||||
urho3d.LOCAL by default, avoiding the problems of accidentally using
|
||||
urho3d.REPLICATED on the client.
|
||||
|
||||
Make sure to not set anything to that resource of the node on the server
|
||||
side, because then you will get unpredictable fighting between the one set
|
||||
@ -155,9 +157,9 @@ replicate.main_scene
|
||||
viewport. Add your local stuff to this as needed.
|
||||
- You don't have to use this if you wish to synchronize your scene in a custom
|
||||
way.
|
||||
- Remember to specify urho3d.LOCAL to both CreateNode and CreateComponent,
|
||||
otherwise they will end up in the synchronized ID space and will be overridden
|
||||
by data coming from the server.
|
||||
- CreateNode and CreateComponent uses urho3d.LOCAL by default unlike native
|
||||
Urho3D. With urho3d.REPLICATED (native default) they will end up in the
|
||||
synchronized ID space and will be overridden by data coming from the server.
|
||||
|
||||
|
||||
Unsafe interfaces of built-in extensions
|
||||
|
@ -199,7 +199,7 @@ function M.define(dst, util)
|
||||
if mode ~= nil then
|
||||
return util.wrap_instance("Node", self:CreateChild(name, mode))
|
||||
else
|
||||
return util.wrap_instance("Node", self:CreateChild(name))
|
||||
return util.wrap_instance("Node", self:CreateChild(name, LOCAL))
|
||||
end
|
||||
end
|
||||
),
|
||||
@ -210,7 +210,7 @@ function M.define(dst, util)
|
||||
if mode ~= nil then
|
||||
component = self:CreateComponent(name, mode)
|
||||
else
|
||||
component = self:CreateComponent(name)
|
||||
component = self:CreateComponent(name, LOCAL)
|
||||
end
|
||||
assert(component)
|
||||
return util.wrap_instance(name, component)
|
||||
|
@ -11,8 +11,8 @@ local replicate = require("buildat/extension/replicate")
|
||||
local scene = replicate.main_scene
|
||||
|
||||
-- Add a camera so we can look at the scene
|
||||
local camera_node = scene:CreateChild("Camera", magic.LOCAL)
|
||||
camera_node:CreateComponent("Camera", magic.LOCAL)
|
||||
local camera_node = scene:CreateChild("Camera")
|
||||
camera_node:CreateComponent("Camera")
|
||||
camera_node.position = magic.Vector3(7.0, 7.0, 7.0)
|
||||
camera_node:LookAt(magic.Vector3(0, 1, 0))
|
||||
|
||||
@ -44,7 +44,7 @@ magic.sub_sync_node_added({}, function(node)
|
||||
if name == "Box" then
|
||||
-- Models and materials can be created dynamically on the client side
|
||||
-- like this
|
||||
local object = node:CreateComponent("StaticModel", magic.LOCAL)
|
||||
local object = node:CreateComponent("StaticModel")
|
||||
object.model = magic.cache:GetResource("Model", "Models/Box.mdl")
|
||||
object.material = magic.Material:new()
|
||||
object.material:SetTechnique(0,
|
||||
|
Loading…
x
Reference in New Issue
Block a user