public void FireSkill1() { //Start posiiton for the particle effect to begin at Vector3 firePos = new Vector3(projectilePos.transform.position.x, projectilePos.transform.position.y, projectilePos.transform.position.z); //A new hit point that has the y value higher to be level with the character //Stops the projectile from hitting the ground Vector3 newHitPoint = attackRaycastHit.point; newHitPoint.y = firePos.y; //Instantiate the particle projectile at the fire position location. GameObject projectile = Instantiate(skill1, firePos, Quaternion.identity) as GameObject; //Rotate projectile to look at attack point projectile.transform.LookAt(newHitPoint); //Add a rigid body and add force to move it towards the location projectile.GetComponent <Rigidbody>().AddForce(projectile.transform.forward * 1000); //Set new projectile rotation because rotation is off float newNum = projectile.transform.eulerAngles.y + arrowYRotationOffset; projectile.transform.eulerAngles = new Vector3(projectile.transform.eulerAngles.x, newNum, projectile.transform.eulerAngles.z); Player_Arrow_Collision arrowScr = projectile.GetComponent <Player_Arrow_Collision>(); arrowScr.SetAttack(skill1Damage); Destroy(projectile, 7f); }
public void ArrowInstantiateHelper(Vector3 firePosition, Vector3 attackPoint) { //Instantiate the particle projectile at the fire position location. GameObject projectile = Instantiate(skill, firePosition, Quaternion.identity) as GameObject; //Rotate projectile to look at attack point projectile.transform.LookAt(attackPoint); //Add a rigid body and add force to move it towards the location projectile.GetComponent <Rigidbody>().AddForce(projectile.transform.forward * 1000); //Set new projectile rotation because rotation is off float newNum = projectile.transform.eulerAngles.y + 92f; projectile.transform.eulerAngles = new Vector3(projectile.transform.eulerAngles.x, newNum, projectile.transform.eulerAngles.z); Player_Arrow_Collision arrowScr = projectile.GetComponent <Player_Arrow_Collision>(); arrowScr.SetAttack(damage); Destroy(projectile, 4f); }