]> git.lizzy.rs Git - SuperMouseAdventure.git/blob - 2DGame/Assets/Scripts/Maus/Scissors.cs
Scheren übernehmen Bewegung der Maus
[SuperMouseAdventure.git] / 2DGame / Assets / Scripts / Maus / Scissors.cs
1 using System;
2 using System.Collections;
3 using System.Collections.Generic;
4 using UnityEngine;
5
6 public class Scissors : MonoBehaviour
7 {
8     [SerializeField]
9     float speed;
10
11     [SerializeField]
12     float lifeTime = 10;
13
14     public void StartShoot(bool isFacingLeft, Vector2 velocity)
15     {
16         Rigidbody2D rb2d = GetComponent<Rigidbody2D>();
17         transform.localScale = new Vector3(0.4f, 0.4f, 1);
18
19         if (isFacingLeft == true)
20         {
21             rb2d.velocity = new Vector2(-speed, 0) + velocity;
22         }
23         else
24         {
25             rb2d.velocity = new Vector2(speed, 0) + velocity;
26         }
27
28         Vector2 movementDirection = rb2d.velocity;
29                 movementDirection.Normalize();
30                 transform.rotation = Quaternion.LookRotation(Vector3.forward, movementDirection) * Quaternion.Euler(0, 0, 90);
31
32         Destroy(gameObject, lifeTime);
33     }
34 }