void Start() { controller = GetComponent <InputController> (); collisionInfo = GetComponent <PlayerCollisionInfo> (); actionController = GetComponent <ActionController> (); positionPrevious = new Vector2(transform.position.x, transform.position.y); }
//Also, the enemies deal damage directly to the player if they touch them //Coldier not working at ALL void OnTriggerEnter2D(Collider2D activator) { Debug.Log("HIT"); if (activator.CompareTag("PlayerCollision")) { //If player not invincible (need to add this) //Should only bounce back in straight directions PlayerCollisionInfo P = activator.GetComponent <PlayerCollisionInfo>(); PlayerControl pControl = P.myPlayerControl;//Force for the push, might be changed in the future //I migrated everything over to the player, so that other objects can also deal knockback pControl.EnemyCollision(transform.position, -1); //if(!pControl.invincibility) { //pControl.invincibility = true;//Needs to also pause the player //pControl.invincibilityTime = pControl.maxInvincibilityTime; //Rigidbody2D rb = P.myPlayer.GetComponent<Rigidbody2D>(); //Vector3 vectorFromMonsterToPlayer = activator.transform.position - transform.position; //vectorFromMonsterToPlayer.Normalize(); //Vector2 my2Dvector = new Vector2(vectorFromMonsterToPlayer.x, vectorFromMonsterToPlayer.y ); //Vector2 myVector = CalculateVector(vectorFromMonsterToPlayer); //rb.velocity = myVector * pControl.force; //Force needs to be stopped in the future //P.myHeartSystem.TakenDamage(-1); //} } }
void OnTriggerEnter2D(Collider2D activator) { if (activator.CompareTag("PlayerCollision")) { //The player takes damage unless their shield is up, and the fireball is destroyed if (activator.transform.eulerAngles.z == 90f) { } else { //Deals damage to the player (1/2 or 1?) PlayerCollisionInfo P = activator.GetComponent <PlayerCollisionInfo>(); PlayerControl pControl = P.myPlayerControl; pControl.EnemyCollision(transform.position, -1); } Destroy(this.gameObject); } }
public override void Start() { collisions = new PlayerCollisionInfo(); base.Start(); }
private void Awake() { _mouseInput = Camera.main.GetComponent <MouseInput>(); _rigidbody = GetComponent <Rigidbody2D>(); _playerCollision = GetComponent <PlayerCollisionInfo>(); }
private void Start() { _rigidbody = GetComponent <Rigidbody2D>(); _playerCollisionInfo = GetComponent <PlayerCollisionInfo>(); _audioSource = GetComponent <AudioSource>(); }