0 votes

Is it possible to make such a duplicate node, so that they completely synchronized each other? For example, I have a node with an item and I want its duplicates to be fully synchronized in the hand, in the inventory and in the view window

Godot version v3.5.stable.mono.official [991bb6ac7]
in Engine by (36 points)
retagged by

What do you mean synchronized ? Doing the same functions in real time, sharing the same resources ?? Explain your example more

https://imgur.com/a/zZzYpkl

Here's an example from Escape From Tarkov. This weapon is in the hand slot, can be viewed in the view window, and is also taken in hand in 3d. All these weapons are in different conditions and behave differently, but they are all in sync (flashlight on, scope on, etc.) as if they were different parent nodes using the same child node.

1 Answer

0 votes

It is exactly opposite situation of duplicated node. It is a single data block used to instantiate and shape 3 different nodes. I believe it is executed this way :

  1. There is a dictionary or a node for every weapon, like "machinegun", containing info about its properties, like "mesh" "maxammo" "upgrade" "range" "cost" "isin_inventory" and so on.
  2. It is set to send a signal whenever any property is changed within it. Signal contains information about node name and all its properties after change
  3. Three different nodes are connected to this signal : graphical representation of a weapon, UI representing statistics of a weapon, viewport conatiner showing current mesh of a weapon. They are reacting to specific properties change in signals.

So there are potentially infinite amount of data blocks for weapons, that are invisible in game.
There are three nodes entirely independent from each other, but they are dependent on a signal sent by these data-blocks representing weapons.
There are no duplicates, only a class ( weapon ), that all weapons inherit from

by (7,753 points)

The problem is that it's not just a mesh, but a scene with different nodes (e.g., SpotLight). So, I need to send signals to duplicate this scene in all places where it will be displayed?

No, don't duplicate any scene.
Look, You will have some weapons nodes stored in array, not childed to anything.
This is an example of how it can work :

Your menu mode has reference to array of weapon nodes, and when player chooses weapon name, subsequent weapon node becomes "current" and it sends a signal.

Wievport container node consists only of camera, light, background and empty mesh instance. It catches the signal about weapon, and mesh changes accoriding to information about this weapon.

func on_signal_sent(info)
    MeshInstance.mesh = info.mesh

The player is very complicated set of nodes, but it also receives this signal, so he can adapt in-game statistics like reload time, shot damage, ammo type, zoom-in possibility, some special effects and everything, that depends on weapon type. Player also has an empty mesh, attached to the hands bone, that only changes mesh to a current weapon, nothing else.

Finally, UI element receive this signal, so all its submenus and labels can display statistics of a current weapon.
Whenever a statistic changes, for example You apply upgrade to a weapon, signal is resent, and all these nodes make changes too.

One signal comes from one node, but all amount of nodes can receive it, so nothing needs to be duplicated.

I understand what you're talking about, but the weapon should be a scene, not a mesh. Unfortunately, the mesh has no light sources and cannot simulate a double render, and without this, the weapon will not be able to have a laser, flashlight and scope.

Upd: That is, I would not want to do hacks with a flat image of scope, light and laser from the center of the screen and etc

no no. You need to think more programmatically.
Lets say You want to have 10 weapons in total. You don't want to create 10 scenes for FPP, 10 more scenes for profiled view in menu, and 10 more scenes for menu displaying statistics.
You want to have 10 data bases, and one scene for FPP visualisation, one scene for profiled view, and just one scene for stats display.
What I am saying is, your player will have a specific visual weapon scene in FPP, and this scene will NOT need every information every weapon has, but just minimum, like a mesh and if its one-handed, if it has laser sight and so on. So when You change your weapon from pistol to shotgun, You don't have to preload and instantiate huge shotgun scene and queue free huge pistol scene, instead only a mesh and some visual gimmicks change.
The same goes for other nodes - they use shared information from signal and only change absolutely nesesarry things.

In the game, which I cited in the example weapon behaves everywhere fully (probably except as an item), in the view window, in the weapon assembly mode and in the 3d hands. To get the same functionality, would I have to somehow add a double scope renderer separately, as well as light and laser nodes for each such situation? And then I'd still have to instantiate the nodes for that anyway. Also I could use to render one player in different places (which would definitely be the scene), a car and other things, and it could also play animations, is there a more versatile way?

Just in case: flashlight, scope, and laser must be nodes since there can be several of them on one weapon.

It is all just a mesh. You can use single weapon 3d asset for all of these things. I would model weapon with all scopes and flashlights and upgrades as separate objects in one 3d file, and name them accordingly while remembering to keep one naming convention for all the weapons I model. This way You can just hide/unhide things when signal provides information about scopes and flashlights.
Perhaps You wish for one scene using asset automatically change when another scene with this asset changes, but this automatization must be done manually. I would just make 3d scene with asset only, to listen to signals mentioned above and make changes to the asset accordingly. You could then use one instance of such scene for hands3d and another one as a child of viewport container with camera for profile display.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.