There are plenty of ways to do all this, and absolute rivers of digital ink already splashed wildly across the interwebs talking about it.
Personally I find that interfaces work nicely with Unity’s existing Component architecture. Some people prefer actual object inheritance but that always feels brittle to me. Your mileage may vary.
Using Interfaces in Unity3D:
SendMessage is kind of antiquated. The way to do things today is to make an interface.
That way you say “is there this interface?” and check if it’s not null, then call the method you want if it is.
Don’t be afraid, it’s pretty simple, and it’s way more powerful. Here, soooper-quickly:
// stick this in its own file, usually IMyInterface.cs
public interface IMyInterface
{
void MyMethod( int arg1, string arg2);
}
Now, in whatever Monobehaviors you have, you implement that interface, which ba…
Looks reasonable... you might get some benefit by extracting common methods into some kind of interface, which is a pattern that works really well with Unity and MonoBehaviors. MBs can then implement specific interfaces and be found because they implement those interfaces.
For instance, you might have an IAttackable interface that can represent a target that can be attacked. Some of its methods might be "what can hurt you?" and "you have been attacked by ..." This also means when a projectile …
Check Youtube for other tutorials about interfaces and working in Unity3D. It’s a pretty powerful combination.
ALSO: be sure to data-drive as much as possible early on to set yourself up for minimal code changes.
ScriptableObject usage in RPGs:
The most important concept about ScriptableObjects (SOs) is that they are custom-shaped blobs of data that you can edit inside the Unity inspector.
The serialized values inside a SO map directly to that created asset on disk, the instance of the SO.
When your game runs, it needs some data. One way to get that data is to hard-code it in the code. That is bad because when you change it, you need to change code. That’s why we have things like a SO to configure existing unchanging shipped code.
W…
This looks like a job tailor made for ScriptableObjects!
ScriptableObjects are basically structured blobs of predefined data to help you create content for your game.
For instance if I had a ScriptableObject called Weapon, it might have these properties:
name
detailed name
description
damage
toughness
weight
what it looks like in the inventory
what model it uses in game
what animations the player uses to swing it
I would create many of these Weapons, each one a file on disk (also called an…
Usage as a shared common data container: