// Called fromt he animator during the animation public void AnimWeapon1Activate() { if (equippedWeapon1.stopsMovement) { myMovementController.TurnOffMovement(); } Vector3 pos = Camera.main.WorldToScreenPoint(transform.position); Vector3 dir = Input.mousePosition - pos; myMovementController.TurnLegsInLineWithBody(); RaycastHit2D immediateFrontCheck = Physics2D.Raycast(projectileStartPos.position, dir, 0.2f, immediateFrontMask); if (immediateFrontCheck.collider != null) { Debug.Log("You are standing right in front of an environment object! I am not even spawning that bullet!"); StartCoroutine(Weapon1Cooldown()); return; } // Actually do the shooting/hitting switch (equippedWeapon1.weapongType) { case weaponTypes.Melee: // Handled inside the animator break; case weaponTypes.Ranged: float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg; Quaternion newRotation = Quaternion.AngleAxis(angle, Vector3.forward); Vector3 newProjectileSpawnPos = new Vector3(equippedWeapon1.projectileSpawnLocalPos.x, equippedWeapon1.projectileSpawnLocalPos.y, 0); if (equippedWeapon1.projectileSpawnLocalPos != Vector2.zero && projectileStartPos.localPosition != newProjectileSpawnPos) { projectileStartPos.transform.localPosition = newProjectileSpawnPos; } Vector2 bulletPos = new Vector2(projectileStartPos.position.x, projectileStartPos.position.y); //WeaponEffects(equippedWeapon1); if (equippedWeapon1.inaccuracyRadius > 0) { newRotation = GenerateRotWithInaccuracy(equippedWeapon1, newRotation); } Bullet newBullet = Instantiate(equippedWeapon1.projectile, bulletPos, newRotation).GetComponent <Bullet>(); newBullet.direction = dir; break; default: break; } }