void OnAttachKnife(object sender, object args) { knifeController = (KnifeController)args; knifeObject = knifeController.gameObject; safeWarpCollider = knifeObject.GetComponentInChildren <SafeWarpCollider>(); colliding = false; transform.position = knifeObject.transform.position; transform.rotation = GlobalGravityControl.GetGravityRotation(); lastUsablePos = knifeObject.transform.position; Enabled(true); }
/* * Throw knife at given strength */ void ThrowKnife(float _strength, bool _secondary = false) { if (currentWarps < 1) { return; } // TODO: replace with consistent knife instances. one for each type // instantiate knife prefab knife = Instantiate((_secondary) ? secondaryKnifePrefab : primaryKnifePrefab, transform.position, GlobalGravityControl.GetGravityRotation()); knifeController = knife.GetComponent <KnifeController>(); // check that we have actually got a knife if (knifeController == null) { Debug.LogError("No KnifeController found on knife prefab"); return; } // set up and throw knife object knifeController.Setup(knifeInHand.transform, warpLookAheadCollider); knifeController.Throw(transform.forward * _strength); // hide knife view object HideKnife(true); }
void OnGravityChangeNotification(object sender, object args) { currentGravVector = GlobalGravityControl.GetCurrentGravityVector(); currentGravRotation = GlobalGravityControl.GetGravityRotation(); }