Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class ActionBlock : MonoBehaviour {
- public int value;
- public Vector2 vector;
- public GameObject Parent;
- GameObject enteredObject;
- int count;
- private void Update()
- {
- if (active)
- {
- if (count == value)
- {
- vector = Vector2.Reflect(vector, vector);
- }
- Parent.transform.Translate(vector * Time.deltaTime);
- if(enteredObject != null)
- enteredObject.transform.Translate(vector * Time.deltaTime);
- count++;
- }
- }
- // Use this for initialization
- void Start () {
- }
- bool active = false;
- void OnTriggerEnter2D(Collider2D collider)
- {
- if (collider.CompareTag("Player"))
- {
- enteredObject = collider.gameObject;
- if (!active)
- {
- active = true;
- }
- }
- }
- void OnTriggerExit2D(Collider2D collider)
- {
- enteredObject = null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement