religion/Assets/Scripts/Hammer.cs
Roman 1802f8ee83 任务:搭建基本的系统
1.绑定cinemaMachine相机
2.修复锤子攻击后玩家反而被击飞的Bug
(1.为了避免锤子碰撞体抵到地面、锤子将怪物按在地上等问题,现需要将锤子改为触发器,锤子的判定代码移至锤子类
2.替换锤子攻击动画为攻击范围加长一版
2021-12-01 19:14:21 +08:00

21 lines
531 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 锤子类,主要判定下攻击
/// </summary>
public class Hammer : MonoBehaviour
{
//当有东西进入触发器
public void OnTriggerEnter2D(Collider2D other){
//看看是不是敌人
if(other.TryGetComponent<Enemy>(out Enemy enemy)){
enemy.OnBeHit(MyPlayer.AtkMethod.,
(enemy.transform.position.x -
transform.position.x > 0) ? -1 : 1);
}
}
}