What I am wanting to have, its a kind of static Unique (Their own instances in reference to the caller) script that can be used and accessed by all.This script will take data (Stats and Equipment stats) and do a combat based calculation and return the result to the caller. It will also instruct the caller what animation to play.
Is there any technique or ideas on how I can implement this?
Would this have a negative effort on performance?
Would I be better off having this script attached to all actors (PC and NPCs)?
Hello,
Typically, singletons is the way to go. It’s even better to group up your calculations to avoid having unexpected stuff going on because of a script you’d be overlooking, but keep in mind that everything will be calculated OnUpdate() or OnFixedUpdate() and may not be 100% smooth on a very large project with a lot of heavy lifting.
You don’t actually need to hardcode a singleton pattern, this sort of class is sometimes called a GameManager (if you call your script GameManager, it should even have a special gear icon to it), but beware, it becomes a mess very fast.
There is a fine balancing between multiple components with OnUpdate() methods and one component with a big one. The optimization intersection between the two is really a matter of design choices and careful planning.
Yeah, for a RPG with little fights having one manager doing the heavy lifting seems like the best approach.