public void Fire(int playerID) { SM.PlaySFX(SFX.Fire); Transform shell = (Transform)Instantiate(Shell, FirePos.transform.position, FirePos.transform.rotation); ShellScript ss = shell.GetComponent <ShellScript>(); ss.OwnerID = playerID; ss.dmg = C_Damage; ss.type = ShellType.Standard; Color MyColor = _Help.V3ToColor(_MyV3Color); ss.color = MyColor; // Get Shell to ignore Firing Units Collider // https://docs.unity3d.com/ScriptReference/Physics.IgnoreCollision.html (03 Nov 2018) Physics.IgnoreCollision(ss.GetComponent <Collider>(), Col); }
void FixedUpdate() { // This logic should probably go into bulletCamState... if (!hasPenetratedBefore) { const float kMaxOwnerNearDistance = 10.0f; Time.timeScale = Mathf.Lerp(0.01f * 0.5f, 1.0f * 0.5f, shellScript.DistanceTraveled / kMaxOwnerNearDistance); Time.fixedDeltaTime = originalFixedDeltaTime * Time.timeScale; if (Time.timeScale == 1.0f) { RaycastHit hitInfo; var rigidBody = shellScript.GetComponent <Rigidbody>(); const float lookAheadDistance = 100.0f; if (Physics.Raycast(shellScript.transform.position, rigidBody.velocity, out hitInfo, lookAheadDistance)) { Time.timeScale = TimeScaleApproachCurve.Evaluate(1.0f - hitInfo.distance / lookAheadDistance); // Debug.Log("PostCurve newTimeScale: " + Time.timeScale); } } } }