public void Init() { if (effects == null) { effects = gameObject.AddComponent <EffectsShepherd>(); effects.Init(); } controller = AddControllerOfType(DesiredController); controller.Init(effects); controller.SetMaxVelocity(100f); detectionRadius = gameObject.AddComponent <DetectionRadius>(); detectionRadius.Init(10); }
public void Init(EffectsShepherd effects) { Effects = GetComponent <EffectsShepherd>(); CachedRigidbody2D = GetComponent <Rigidbody2D>(); // IMPORTANT: If drag is 1f, Mass is 1f and ForceMode is set to Impulse, Force^2 = MaxVelocity. Ex: 2f^2 = 4 maxVel. // This means that we can calculate the needed constant force from the maximum velocity; // we can set a top speed and calculate the force needed to get there. CachedRigidbody2D.drag = 1f; // Sets default values SetMaxVelocity(25f); SetTurnSpeed(2f); IsInputActive = false; IsMovingRight = false; IsInitialized = true; }
public void Init() { if (effects == null) { effects = gameObject.AddComponent <EffectsShepherd>(); effects.Init(); } #if UNITY_EDITOR || UNITY_STANDALONE || UNITY_WEBGL _desiredController = Controller.Keyboard; #endif ControllerInstance = AddControllerOfType(_desiredController); ControllerInstance.Init(effects); ControllerInstance.SetMaxVelocity(150f); detectionRadius = gameObject.AddComponent <DetectionRadius>(); detectionRadius.Init(10); }
public void Init() { Effects = GetComponent <EffectsShepherd>(); cachedRigidbody2D = GetComponent <Rigidbody2D>(); if (!cachedRigidbody2D) { #if DEBUG Debug.LogWarning("Missing Rigidbody2D on " + name); #endif return; } // IMPORTANT: If drag is 1f, Mass is 1f and ForceMode is set to Impulse, Force^2 = MaxVelocity. Ex: 2f^2 = 4 maxVel. // This means that we can calculate the needed constant force from the maximum velocity; // we can set a top speed and calculate the force needed to get there. cachedRigidbody2D.drag = 1f; forwardForce = Mathf.Sqrt(_maxVelocity); isInitialized = true; }