public override void Cast(GameActor caster, UnityEngine.Vector3 target) { Ray ray = Camera.main.ScreenPointToRay(target); RaycastHit hit; LayerMask layerMask = 1 << LayerMask.NameToLayer("Ground"); if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask.value)) { //hit.point.Set(hit.point.x, 1, hit.point.z); SpellObject spellObj = null; if (PhotonNetwork.offlineMode) { spellObj = GameObjectPool.Spawn(SpellObject.gameObject).GetComponent <SpellObject>(); } else { spellObj = PhotonNetwork.Instantiate(SpellObject.gameObject.name, Vector3.zero, Quaternion.identity, 0).GetComponent <SpellObject>(); } if (!spellObj.photonView.isMine) { spellObj.photonView.TransferOwnership(caster.photonView.ownerId); } spellObj.transform.position = hit.point; spellObj.transform.localScale = Vector3.one; spellObj.SetProps(this); spellObj.transform.LookAt(caster.transform.position); } }
public override void Cast(GameActor caster) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 10000)) { SpellObject spellObj = null; if (PhotonNetwork.offlineMode) { spellObj = GameObjectPool.Spawn(SpellObject.gameObject).GetComponent <SpellObject>(); } else { spellObj = PhotonNetwork.Instantiate(SpellObject.gameObject.name, Vector3.zero, Quaternion.identity, 0).GetComponent <SpellObject>(); } if (!spellObj.photonView.isMine) { spellObj.photonView.TransferOwnership(caster.photonView.ownerId); } spellObj.transform.position = hit.point; spellObj.SetProps(this); spellObj.transform.LookAt(caster.transform.position); } }
public override void Cast(GameActor caster, Vector3 target) { _caster = caster; if (!PhotonNetwork.offlineMode) { _spellObject = PhotonNetwork.Instantiate(SpellObject.name, Vector3.zero, Quaternion.identity, 0) .GetComponent <SpellObject>(); } else { _spellObject = GameObjectPool.Spawn(SpellObject.gameObject).GetComponent <SpellObject>(); } _spellObject.SetProps(this); if (!_spellObject.photonView.isMine) { _spellObject.photonView.TransferOwnership(_caster.photonView.ownerId); } _spellObject.transform.position = caster.transform.position + caster.transform.forward * 1.5f; _spellObject.transform.localScale = Vector3.one; _spellObject.transform.LookAt(target); _spellObject.StartCoroutine(MoveSpell()); }