Pie.cs 1.19 KB
Newer Older
1
2
3
4
5
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Pie : MonoBehaviour {
6
7
    [HideInInspector]
    public float force;// an number from zero to one determining the force on the pie
8

9
10
    public float minForce = 4f;
    public float maxForce = 8f;
11

12
13
    // Use this for initialization
    void Start () {
14
        Launch();
15
16
17
18
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
19
20
        PieManager.pieInScene = false;
        PieManager.start = false;
21
22
23
24
25
26
27
28
29
        if (collision.GetComponent<PieTarget>())
        {
            Destroy(gameObject);
        }
        else
        {
            gameObject.GetComponent<Rigidbody2D>().velocity = new Vector2(0, 0);
            gameObject.GetComponent<Rigidbody2D>().gravityScale = 0;
        }
30
31
    }

32
33
    private void Update()
    {
astatham's avatar
astatham committed
34
        
35
36
37
    }

    void Launch(){
38
39
40
41
        //Vector3 direction = Quaternion.AngleAxis(Needle.finalAngle, Vector3.forward) * Vector3.right;
        float forceAmmount = (force * (maxForce - minForce)) + minForce;
        //print(forceAmmount);
        gameObject.GetComponent<Rigidbody2D>().AddForce(transform.up * forceAmmount * 100);
42
43
    }
}