using System.Collections;using System.Collections.Generic;using UnityEngine;publicclassPlayerHp:MonoBehaviour{publicfloat Hp =100;// Start is called before the first frame updatevoidStart(){}// Update is called once per framevoidUpdate(){}publicvoidTakeDamage(){if(Hp <=0){GetComponent<PlayerMove>().enabled =false;}}}
using System.Collections;using System.Collections.Generic;using UnityEngine;publicclassPlayerHp:MonoBehaviour{publicfloat Hp =100;// Start is called before the first frame updatevoidStart(){}// Update is called once per framevoidUpdate(){}publicvoidTakeDamage(){if(Hp <=0){//可以直接调用public方法GetComponent<PlayerMove>().MoveToFloor();}}}