基本信息
源码名称:豆子现身Unity射击类小游戏
源码大小:35.28M
文件格式:.rar
开发语言:C#
更新时间:2020-05-31
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍
射击类小游戏

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class player_hp : MonoBehaviour
{
    public int Hp=3;
    public float lastTime;
    void OnCollisionEnter2D(Collision2D col){
        if(col.gameObject.tag=="enemy"){
            if(Time.time>lastTime 2){
                Hp--;
                Vector3 v=
                (transform.position-col.transform.position) Vector3.up*5;
                GetComponent<Rigidbody2D>().AddForce(v*50);
                lastTime=Time.time;
            }
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if(Hp<=0){
            Destroy(gameObject);
        }
    }
}