// Start is called before the first frame update void Start() { rb = GetComponent <Rigidbody>(); anim = gameObject.GetComponentInChildren <Animator>(); //Fills the camScript variable with the script attached to the camera game object. camScript = currentCam.GetComponent <PlayerCam>(); }
/// <summary> /// Handles the player's firing logic and setting raycasts. /// </summary> protected void Fire() { if (_reloading) { return; } waitTime = Time.time + _attackTime; RaycastHit hitInfo; // Sets the middle of the players view as our start point Vector3 rayStart = PlayerCam.ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 0)); Debug.DrawRay(rayStart, PlayerCam.transform.forward * 5000f, Color.red); if (Physics.Raycast(rayStart, PlayerCam.transform.forward, out hitInfo, 5000f)) { Transform go = hitInfo.transform; if (go.tag.Equals("Enemy")) { go.GetComponent <PhotonView>().RPC("TakeDamage", PhotonTargets.MasterClient, _damage); } } numberOfBulletsInGun--; UpdateGunAmmo(); // Plays the muzzle flash _muzzleFlash.Play(); // Plays the weapon sound _weaponSound.PlayShotSound(); }
//public bool reloaded = true; public override void Shoot() { if (reloaded == true) { ShotAudio.Play(); LazerBeam.enabled = true; Ray ray = PlayerCam.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2) /*new Vector3(0.5f, 0, 0.5f)*/); //ray.origin = PlayerCam.transform.position; LazerBeam.SetPosition(0, Vector3.zero); Invoke(nameof(LazerOff), 0.2f); Invoke(nameof(Reload), 2.5f); reloaded = false; if (Physics.Raycast(ray, out RaycastHit hit)) { LazerBeam.SetPosition(1, transform.InverseTransformPoint(hit.point)); PlayerScript.DrawShotLine(1, hit.point); if (hit.collider.gameObject.GetComponent <PlayerController>() != null) { hit.collider.gameObject.GetComponent <PlayerController>().TakeDamage(damage); //PlayerScript.TakeDamage(); } Debug.Log("We hit" + hit.collider.name); } else { LazerBeam.SetPosition(1, new Vector3(580, -4547, 40)); PlayerScript.DrawShotLine(1, new Vector3(580, -4547, 40)); } } }
void Update() { if (!PlayerLook.instance.isDisabled) { PlayerCam cachedPCamInstance = PlayerCam.instance; if (cachedPCamInstance && cachedPCamInstance.cam && Input.GetMouseButtonDown(0)) { if (Physics.Raycast( cachedPCamInstance.cam.transform.position, cachedPCamInstance.cam.transform.forward, out RaycastHit hit, range, itemMask )) { if (hit.transform.gameObject.GetComponent <Interactable>()) { hit.transform.gameObject.GetComponent <Interactable>().Interact(); } } } //if (Physics.Raycast( // cachedPCamInstance.cam.transform.position, // cachedPCamInstance.cam.transform.forward, // out RaycastHit hit2, // range, // itemMask // )) //{ // hit2.transform.gameObject.GetComponent<Renderer>().material.SetFloat("_SecondOutlineWidth", hit2.transform.gameObject.GetComponent<Interactable>().hoveringOutlineWidth); //} } }
// Use this for initialization void Start() { m_HitManger.OnHitAction += PlayerHitAction; m_HitManger.OnDragAction += FixPlayerCam; m_MoveManger.OnMove += PlayerMove; mLocalPlayer = UIManager.LocalPlayer; mLocalPlayerCam = UIManager.LocalPlayerCam; }
public void Exit() { gameObject.SetActive(false); ButtonsAnimator.SetTrigger("Close"); minimap.SetActive(true); Movement.isPaused = false; PlayerCam.SetActive(true); ShopCam.SetActive(false); ShopCam.GetComponent <CinemachineVirtualCamera>().LookAt = null; }
public void Activate() { gameObject.SetActive(true); minimap.SetActive(false); ButtonsAnimator.SetTrigger("Open"); ShopCam.SetActive(true); PlayerCam = GameObject.Find("Player").transform.GetChild(6).gameObject; PlayerCam.SetActive(false); ShopCam.GetComponent <CinemachineVirtualCamera>().LookAt = Merchant.transform; Movement.isPaused = true; }
// Use this for initialization void Start() { firstPersonCam = transform.Find("FirstPersonCharacter"); thirdPersonCam = transform.Find("ThirdPersonCharacter"); thirdPerson = thirdPersonCam.GetComponent<Camera>(); firstPerson = firstPersonCam.GetComponent<Camera>(); firstPersonAudio = firstPersonCam.GetComponent<AudioListener>(); thirdPersonAudio = thirdPersonCam.GetComponent<AudioListener>(); firstPersonCameraScript = firstPersonCam.GetComponent<PlayerCam>(); thirdPersonCameraScript = thirdPersonCam.GetComponent<PlayerCam>(); }
public override void OnStartLocalPlayer() { enabled = isLocalPlayer; Debug.LogFormat(name + " : " + isLocalPlayer); if (isLocalPlayer) { mPlayerCam = PlayerCam.Instance; mPlayerCam.SetTarget(RoleFixedPoint.BodyTs); UIManager.Instance.SetLocalPlayer(mPlayerController, mPlayerCam); /* mPlayerController.uiSet(); mPlayerController.Listencontroll = true; */ //GameManager.SetLocalPlayer(gameObject, netId); //GameManager.SetLocalParam(netId); } }
public override void Shoot() { if (reloaded == true && Time.time >= nextfire) { if (WorkingParticleSystem == false) { flash.Play(); WorkingParticleSystem = true; PlayerScript.ShowMachineGunShooting(true); } ShotAudio.Play(); nextfire = Time.time + 1f / fireRate; RaycastHit hit; if (Physics.Raycast(PlayerCam.ScreenPointToRay(new Vector2(Screen.width / 2, Screen.height / 2)), out hit)) { if (hit.collider.gameObject.GetComponent <PlayerController>() != null) { hit.collider.gameObject.GetComponent <PlayerController>().TakeDamage(damage); } Debug.Log("We hit" + hit.collider.name); } } }
void Awake() { mInstance = this; mTs = transform; }
void Start () { cam = transform.FindChild("Camera").GetComponent<Camera>(); playerCam = GameObject.FindWithTag("Player").GetComponent<PlayerCam>(); }
public void SetLocalPlayer(PlayerController player, PlayerCam cam) { mLocalPlayerControler = player; mLocalPlayerCam = cam; }
public void UpdateSens(float val) { PlayerPrefs.SetFloat("sens", val); PlayerCam.SetSensitivity(val); }
private void Awake() { instance = this; }
void Awake() { instance = this; }
void Awake() { _player = GetComponent <Player>(); _cam = GetComponent <PlayerCam>(); }
void OnDestroy() { mInstance = null; }
// Use this for initialization void Awake() { _cam = cam.GetComponent <PlayerCam>(); cc = GetComponent <CharacterController>(); currentSpeed = 7; }
private void Start() { playCamTf = GameObject.Find("Main Camera").GetComponent <Transform>(); playCam = playCamTf.GetComponent <PlayerCam>(); }