Monday, August 22, 2022
HomeGame Developmentstructure - Modelling Two Approach Relationship in Unity for Scriptable Objects

structure – Modelling Two Approach Relationship in Unity for Scriptable Objects


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

As an example we’ve quite a lot of gadgets in-game, and every merchandise might be obtained by totally different situations. Some might 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 might 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 means relationships like this?

For gadgets alone, it could be easiy to deal with… however as you may 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 might provide you with quite a lot of methods:

  1. Have two scriptable objects references one another, however 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. However what if we need 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 throughout the Unity Editor.

But, not one of the strategies appears to be the correct answer and every have their advantages and points. Earlier than committing to refactoring our sport (We’re utilizing methodology 2 in the mean time), I determine it will be nice to ask for some advices on this website. How do you normally take care of this type of points?

Thanks!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments