﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TrampolinScript : MonoBehaviour
{
    public float speed = 1000;
    public bool useOwnUp = true;
    public Vector3 customDirection = new Vector3(1,0,0);

    private void OnTriggerEnter(Collider collision)
    {
        Rigidbody rb = collision.gameObject.GetComponent<Rigidbody>();

        if (rb != null)
        {
            if (useOwnUp)
            {
                rb.velocity = new Vector3(0, 0, 0);
                rb.AddForce(transform.up * speed, ForceMode.Acceleration); 
            } else
            {
                rb.velocity = new Vector3(0, 0, 0);
                rb.AddForce(customDirection * speed, ForceMode.Acceleration);
            }
        }
    }
}
