void Start() { rb = GetComponent <Rigidbody>(); kiihtyvyys *= rb.mass; pelaaja = GameObject.FindGameObjectWithTag("Player"); npScripti = GetComponent <NakeekoPelaajan>(); vsScripti = GetComponent <VihollisenSeuraus>(); lpScripti = GetComponent <LyoPelaajaa>(); animaatiot = GetComponent <Animator>(); }
public void Cast() { Ray ray = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0)); RaycastHit[] raycastHits = Physics.RaycastAll(ray, Mathf.Infinity); raycastHits = NakeekoPelaajan.JarjestaPituudenMukaan(raycastHits); Vector3 hitPosition = transform.position + transform.forward; foreach (RaycastHit hit in raycastHits) { if (hit.transform.tag != "Item" && hit.transform.tag != "Player") { hitPosition = hit.point; break; } } Vector3 castDirection = (hitPosition - transform.position).normalized; GameObject spellInstance = Instantiate(spell, transform.position, Quaternion.identity); spellInstance.GetComponent <Rigidbody>().AddForce(castDirection * projectileSpeed, ForceMode.Impulse); }
private void Start() { npScripti = GetComponent <NakeekoPelaajan>(); pitaakoSeurata = false; }
private void Start() { pelaaja = GameObject.FindGameObjectWithTag("Player"); animaatiot = GetComponent <Animator>(); npScripti = GetComponent <NakeekoPelaajan>(); }