// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray = new Ray(playWeapon.position, playWeapon.forward);//Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out RaycastHit hit, 100.0f)) { Splatter splatter = hit.collider.gameObject.GetComponent <Splatter>(); if (splatter != null) { splatter.Splat(ray.direction, hit.normal, hit.point); } } } if (Input.GetKey(KeyCode.W)) { transform.Translate(Vector3.forward * speed * Time.deltaTime); } if (Input.GetKey(KeyCode.S)) { transform.Translate(Vector3.back * (speed / 2) * Time.deltaTime); } transform.Rotate(new Vector3(0, Input.GetAxis("Mouse X"), 0) * Time.deltaTime * rotateSpeed); }
void Update() { if (!isLocalPlayer) { return; } if (Input.GetMouseButton(0)) { _emitter.Splat(); } _motion = Vector3.zero; var x = Input.GetAxis("Horizontal") * Time.deltaTime * PlayerRunSpeed; var z = Input.GetAxis("Vertical") * Time.deltaTime * PlayerRunSpeed; var rotation = Input.GetAxis("Mouse X") * MouseSpeed; _pitch -= Input.GetAxis("Mouse Y") * MouseSpeed; _pitch = Mathf.Clamp(_pitch, -CameraPitchClamp, CameraPitchClamp); //transform.Translate(x, 0, z); transform.Rotate(0, rotation, 0); _motion = new Vector3(x, 0, z); _motion = transform.TransformDirection(_motion); _front.Move(_motion); _camera.localRotation = Quaternion.AngleAxis(_pitch, Vector3.right); }
void Update() { if (!isLocalPlayer) { return; } /*if(!g.hasObject){ * Grabbable gg = g.GetGrabbable(); * if (gg) * { * LeftArm.transform.localRotation = Quaternion.Lerp(_leftDownRotation, _leftGrabRotation, Time.time * .1f); * RightArm.transform.localRotation = Quaternion.Lerp(_rightDownRotation, _rightGrabRotation, Time.time * .1f); * } * else * { * LeftArm.transform.localRotation = Quaternion.Lerp(_leftGrabRotation, _leftDownRotation, Time.time / .1f); * RightArm.transform.localRotation = Quaternion.Lerp(_rightGrabRotation, _rightDownRotation, Time.time * .1f); * } * }*/ if (Input.GetMouseButton(0)) { _emitter.Splat(); if (!_sfx[1].isPlaying && g.hasMop) { _sfx[1].pitch = Random.Range(1.0f, 1.2f); _sfx[1].Play(); } if (!_mopping && g.hasMop) { Debug.Log("Now Mopping"); _mopping = true; _animator.SetBool("isMopping", true); //LeftArm.transform.localRotation = _leftDownRotation; } } else { if (_sfx[1].isPlaying) { _sfx[1].Stop(); } if (_mopping) { Debug.Log("Not Mopping"); _mopping = false; //LeftArm.transform.localRotation = _leftGrabRotation; _animator.SetBool("isMopping", false); } } var x = Input.GetAxis("Horizontal") * transform.right; var z = Input.GetAxis("Vertical") * transform.forward; _motion = (x + z).normalized * PlayerRunSpeed * Time.deltaTime; var rot = Input.GetAxis("Mouse X") * MouseSpeed; _rotation = new Vector3(0, rot, 0) * PlayerTurnSpeed; _pitch -= Input.GetAxis("Mouse Y") * MouseSpeed; _pitch = Mathf.Clamp(_pitch, -CameraPitchClamp, CameraPitchClamp); transform.Rotate(_rotation); _front.Move(_motion); _camera.localRotation = Quaternion.AngleAxis(_pitch, Vector3.right); if (_front.velocity.magnitude > 1) { if (!_sfx[0].isPlaying) { _sfx[0].pitch = Random.Range(1.0f, 1.2f); //walking sounds _sfx[0].Play(); } } else { if (_sfx[0].isPlaying) { _sfx[0].Stop(); } } }
void Update() { if (!isLocalPlayer) { return; } if (isPenned) { SetPenned(false); gameObject.GetComponent <SpawnController>().BeginRespawn(); } _animator.SetFloat("Velocity", _front.velocity.magnitude); if (!isLocalPlayer) { return; } _inputD = _inputH.getInputData(); if (Input.GetKey(KeyCode.F)) //bark { PlaySound(_sfx [0]); } if (_inputD.splat) { _emitter.Splat(); if (!_sfx [4].isPlaying && d.WaterLevel > 0) { _sfx [4].pitch = Random.Range(1.0f, 1.2f); _sfx [4].Play(); } } else { if (_sfx [4].isPlaying) { _sfx [4].Stop(); } } if (_front.velocity.magnitude > 1) { //DoPeePoofs (); if (!_sfx [2].isPlaying) { _sfx [2].pitch = Random.Range(1.0f, 1.2f); //walking sounds _sfx[2].volume = _runStartVolume; _sfx [2].Play(); } } else { if (_sfx [2].isPlaying) { _sfx [2].volume = _runStartVolume * _front.velocity.magnitude; if (_sfx[2].volume <= 0.0f) { _sfx [2].Stop(); } } //StopPeePoofs (); } if (!Input.anyKey) { if (_sfx [2].isPlaying) { _sfx [2].Stop(); } } }