Home Game Development structure – Modelling Two Way Relationship in Unity for Scriptable Objects

structure – Modelling Two Way Relationship in Unity for Scriptable Objects

0
structure – Modelling Two Way Relationship in Unity for Scriptable Objects

[ad_1]

How does one mannequin two-way relationships for scriptable objects?

Let’s say we now have a variety of gadgets in-game, and every merchandise could be obtained by completely different circumstances. Some could require you to finish a sure mission, some could also be purchasable from an NPC, some could also be dropped from an enemy, and a few could require you to buy a DLC…

Given an merchandise, we wish to know what are the ways in which it may very well be obtained; and given a mission/npc/enemy/dlc, we wish to know what gadgets it grants.

What are one of the best methods to mannequin two manner relationships like this?

For gadgets alone, it might be easiy to deal with… however as you possibly can think about, there are much more two-way relationships in video games, between missions and NPC, missions and missions, DLC and NPC… and so forth.

I may provide you with a variety of methods:

  1. Have two scriptable objects references one another, nevertheless it’s error susceptible. So we might want to have some validation logic, or an editor script that updates relationship mechanically when one was modified.

  2. Make one-way reference solely, and have the two-way relationships initialized at runtime. But what if we wish to have the connection displayed within the Unity Editor two-way?

  3. Use an precise relational database like SQL to retailer the connection, and maybe an id/guid reference to the precise scriptable object for straightforward enhancing inside the Unity Editor.

Yet, not one of the strategies appears to be the correct answer and every have their advantages and points. Before committing to refactoring our recreation (We are utilizing technique 2 in the intervening time), I determine it might be nice to ask for some advices on this web site. How do you often take care of this type of points?

Thank you!

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here