private void Awake() { DontDestroyOnLoad(gameObject); if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } }
/// <summary> /// Copy the values from the given event. This allows this Force instance to emulate the force specified in the /// ForceEvent. This is necessary because ForceEvents are not applied on entities directly. It takes a Force instance /// to directly apply a Force on an entity. Therefore, to apply a ForceEvent on an entity, its parameters must first be /// copied into a Force instance, which is then applied on the entity. /// </summary> public void CopyValues(ForceEvent forceEvent) { // Copy the values from the ForceEvent. Note that the ForceEvents do not directly specify a start time or duration. // Rather, it is the Brawler.Event instance which wraps this ForceEvent that specifies it. Further, a ForceEvent // cannot have an OnCompleteEvent. Otherwise, since ForceEvents are wrapped by a Brawler.Event instance, this would // cause a circular recursion which would infinitely create new Brawler.Event and ForceEvent instances forceType = forceEvent.forceType; velocity = forceEvent.velocity; relativeToFacingDirection = forceEvent.relativeToFacingDirection; target = forceEvent.target; customTargetPosition = forceEvent.customTargetPosition; faceTarget = forceEvent.faceTarget; }