void OnCollisionEnter2D(Collision2D collision) { Attackable attackable = collision.gameObject.GetComponent <Attackable>(); if (attackable != null) { attackable.Attacked(attack); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag != "Enemy") { Attackable attackable = collision.gameObject.GetComponent <Attackable>(); if (attackable != null) { attackable.Attacked(fireBallDamage); } if (collision.gameObject.tag == "Player" || collision.gameObject.tag == "Ground") { Invoke("DestroyFireBall", DestroyFireBallAfterCollisionTime); } } }
void OnCollisionEnter2D(Collision2D collision) { Attackable attackable = collision.gameObject.GetComponent <Attackable>(); if (attackable != null) { attackable.Attacked(attack); } /*SI JOUEUR COLLIDER : */ /*if (collision.gameObject.tag == "Player") * { * Invoke("die", DestroyFireBallAfterCollisionTime); * }*/ }
//public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) //{ // throw new System.NotImplementedException(); //} private void MovePlayer() { position = new Vector3(this.transform.position.x, 0, this.transform.position.z); if (Vector3.Distance(position, lastValidMoveTarget) > allowedDelta && isMouseDown) { //Old Solution Vector3 desiredPosition = this.transform.position + this.transform.forward * (Time.deltaTime * moveSpeed); Vector3 bottomSphere = desiredPosition + transform.forward * forwardOffset + bottomOffset; Vector3 topSphere = desiredPosition + transform.forward * forwardOffset + heightOffset; int count = Physics.OverlapCapsuleNonAlloc(bottomSphere, topSphere, overlapRadius, overlapResults); bool canMove = true; for (int i = 0; i < count; i++) { //Debug.Log(overlapResults[i].name); if (overlapResults[i].gameObject.tag == "NoPass") { } } if (canMove) { transform.position = desiredPosition; } } else if (Vector3.Distance(position, lastValidMoveTarget) > allowedDelta && !isMouseDown) { if (Vector3.Distance(position, targetCorner) > allowedDelta) { //Debug.Log("Broken: " + Vector3.Distance(transform.position, targetCorner)); Vector3 offset = transform.forward * (Time.deltaTime * moveSpeed); transform.position += offset; } else { //Debug.Log("In statement"); currentCornerIndex += 1; if (currentCornerIndex < path.corners.Length) { targetCorner = path.corners[currentCornerIndex]; Vector3 lookPoint = targetCorner; lookPoint.y = transform.position.y; transform.LookAt(lookPoint); } else { //Debug.Log("Here"); targetCorner = this.transform.position; if (attackTarget != null) { //Additional Attack code needed!!!!!! Vector3 lookPoint = attackTarget.transform.position; lookPoint.y = this.transform.position.y; this.transform.LookAt(lookPoint); //HAAAAACK attackTarget = null; agent.SetDestination(this.transform.position); attackTarget.Attacked(); currentMode = IDLE; } } } } }