Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class ShotgunBullet : Bullet
- {
- private Vector3 _direction;
- private void Start()
- {
- var rotatedVector = Vector3.left;
- var bulletRotation = transform.rotation.eulerAngles * Mathf.Deg2Rad;
- var x1 = rotatedVector.x * Mathf.Cos(bulletRotation.z) - rotatedVector.y * Mathf.Sin(bulletRotation.z);
- var y1 = rotatedVector.x * Mathf.Sin(bulletRotation.z) + rotatedVector.y * Mathf.Cos(bulletRotation.z);
- _direction = new Vector3(x1, y1, 0).normalized * (Speed * Time.deltaTime);
- }
- private void Update()
- {
- transform.Translate(_direction * (Speed * Time.deltaTime), Space.World);
- TrySelfDestruction(Time.deltaTime);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement