void NonLocalUpdate() { if (User.Health <= 0f) { moveVec = Vector3.zero; } if (cc == null) { cc = GetComponent <CharacterController>(); } if (bod == null) { bod = gameObject.AddComponent <CcBody>(); } float timeDelta = (float)(Network.time - lastUpdateTime); lastUpdateTime = Network.time; bod.UpVector = animObj.transform.up; if (crouching) { bod.Move(moveVec * timeDelta * 5f); } else { bod.Move(moveVec * timeDelta * 10f); } if (bod.yMove <= 0f) { bod.Move(transform.up * -0.2f); bod.grounded = bod.isGrounded; if (!bod.grounded) { bod.Move(transform.up * 0.2f); } } else { bod.grounded = false; } if (bod.grounded) { bod.yMove = 0f; } else { bod.yMove -= timeDelta * 10f; } bod.Move(transform.up * bod.yMove * timeDelta * 5f); }
Vector3 oobGunOffs = new Vector3(0.074f, 0.46f, 0.84f); // offset of gun from aimBone (out of body view) void Start() { // components if (bod == null) { bod = gameObject.AddComponent <CcBody>(); } // get cc = GetComponent <CharacterController>(); var o = GameObject.Find("Main Program"); net = o.GetComponent <CcNet>(); hud = o.GetComponent <Hud>(); arse = o.GetComponent <Arsenal>(); locUser = o.GetComponent <LocalUser>(); // new female model //Model = (GameObject)GameObject.Instantiate(Models.Get("Mia")); //Model.SetActive(true); //Model.hideFlags = HideFlags.None; //.DontSave; // ....to the scene. AND don't DESTROY when new scene loads // the rest is all dependent on User class if (User == null) { return; } if (User.local && net.CurrMatch.pitchBlack) { Camera.main.backgroundColor = Color.black; RenderSettings.ambientLight = Color.black; } if (User.lives >= 0) { if (User.local) { SetModelVisibility(false); } else { SetModelVisibility(true); } Respawn(); } else { // we joined as a spectator SetModelVisibility(false); transform.position = -Vector3.up * 99f; } // get rid of gun1 and gun2 builtin to the avatar MeshInHand.GetComponent <Renderer>().enabled = false; MeshInHand.SetActive(false); MeshOnBack.SetActive(false); MeshOnBack.GetComponent <Renderer>().enabled = false; }