VR模拟枪支打靶,消灭鬼怪,换弹以及上弦等等硬核枪支操作。 使用HTCVive设备,开启SteamVR进行游玩。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

36 lines
1.1 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//光剑
//砍中敌人时计算一段伤害,抽离敌人算第二段伤害
public class LightSword : MonoBehaviour {
public int Damage_;
public float Length;
private bool grounded;
private RaycastHit hit;
public bool isAttacked;
public GameObject Particle;
private void Update()
{
Debug.DrawRay(gameObject.transform.position, gameObject.transform.forward * Length * 2, Color.red);
grounded = Physics.Raycast(gameObject.transform.position, gameObject.transform.forward, out hit,Length * 2f);
if (grounded && !isAttacked)
{
isAttacked = true;
GameObject SwordEffect = Instantiate(Particle);
SwordEffect.transform.position = hit.point + new Vector3(0f,0.1f,0f);
if (hit.transform.tag == "hurtable") {
Hurtable target = hit.transform.GetComponent<Hurtable>();
target.hurt(Damage_);
}
}
else if(!grounded && isAttacked)
{
isAttacked = false;
}
}
}