Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class takeDamage : MonoBehaviour {
- public int health = 3;
- public bool hitJustTaker;
- public float imortallityTime;
- private currentImortallityTime;
- private Rigidbody2D rBody;
- private MoveScript MoveScript;
- // Use this for initialization
- void Start () {
- rBody = transform.GetComponent<Rigidbody2D>();
- MoveScript = transform.GetComponent<MoveScript>();
- }
- // Update is called once per frame
- void Update () {
- currentImortallityTime -= Time.deltaTime;
- if (MoveScript)
- {
- if (MoveScript.invincible || currentImortallityTime > 0)
- {
- Physics2D.IgnoreLayerCollision(10, 9, true);
- }
- else
- {
- Physics2D.IgnoreLayerCollision(10, 9, false);
- }
- }
- }
- void changeHealth(int value)
- {
- health += value;
- }
- void die()
- {
- Destroy(gameObject);
- }
- void push(Vector2 direction)
- {
- rBody.AddForce(direction, ForceMode2D.Impulse);
- }
- void OnCollisionEnter2D(Collision collisionData)
- {
- if(Physics2D.IsTouchingLayers(transform.GetComponent<Collider2D>(), 10))
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement