// Use this for initialization void Start() { smallClone = gameObject; player = FindObjectOfType <charactermovement2> (); spread = player.activeWeapon.spread / 100; projectileSpeed = player.activeWeapon.projectileSpeed; lifetime = player.activeWeapon.projectileLifetime; Destroy(gameObject, lifetime); Vector3 aimPos = transform.position; Vector3 playerPos = player.transform.position; aimPos.x -= playerPos.x; aimPos.y -= playerPos.y; float angle = Mathf.Atan2(aimPos.y, aimPos.x); angle += Random.Range(-spread, spread); float xVelocity = projectileSpeed * Mathf.Cos(angle); float yVelocity = projectileSpeed * Mathf.Sin(angle); //playerVector = player.GetComponent<Rigidbody2D> ().velocity; //GetComponent<Rigidbody2D> ().velocity = new Vector2 (xVelocity + ( playerVector.x * 0.75f ), yVelocity + ( playerVector.y * 0.75f )); velocity = new Vector3(xVelocity + (0.75f), yVelocity + (0.75f), 0f); //velocity = GetComponent<Rigidbody2D>().velocity; }
// Use this for initialization void Start() { audioSource = GetComponent <AudioSource>(); WeaponLevel = 1; currentWave = 1; size = Vector3.zero; canFire = true; player = FindObjectOfType <charactermovement2> (); projectile.GetComponent <Projectile>().damage = damage; }