添加子弹移动
This commit is contained in:
parent
cbafa8479e
commit
5c5edadceb
|
@ -231,7 +231,7 @@ SphereCollider:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1868832759}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_IsTrigger: 1
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Radius: 0.5
|
||||
|
@ -23496,6 +23496,16 @@ PrefabInstance:
|
|||
m_Modification:
|
||||
m_TransformParent: {fileID: 6865737300552731159}
|
||||
m_Modifications:
|
||||
- target: {fileID: 302957159522640772, guid: 91b685a7f0a6f7643b8ae61842f883de,
|
||||
type: 3}
|
||||
propertyPath: m_CastShadows
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 302957159522640772, guid: 91b685a7f0a6f7643b8ae61842f883de,
|
||||
type: 3}
|
||||
propertyPath: m_ReceiveShadows
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5698306997877693391, guid: 91b685a7f0a6f7643b8ae61842f883de,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
|
|
|
@ -5,8 +5,9 @@ using UnityEngine.Events;
|
|||
|
||||
public class ShellBoom : MonoBehaviour
|
||||
{
|
||||
public UnityEvent onShellAttack;
|
||||
public UnityEvent onShellAttack = new UnityEvent();
|
||||
public bool isPlayer = false;
|
||||
public GameObject attackTarget;
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (isPlayer && other.tag == "AttackTarget")
|
||||
|
@ -15,4 +16,15 @@ public class ShellBoom : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (attackTarget != null)
|
||||
{
|
||||
Vector3 direction = transform.localPosition - attackTarget.transform.localPosition;
|
||||
float step = 1 * Time.deltaTime;
|
||||
transform.rotation = Quaternion.LookRotation(direction);
|
||||
transform.localPosition = Vector3.MoveTowards(transform.localPosition, attackTarget.transform.localPosition, step);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -123,17 +123,14 @@ public class DeviceManager : MonoSingleton<DeviceManager>
|
|||
List<UnmannedAerialVehicleManage> temp = GetGXWRJAndZSWRJ();
|
||||
for (int i = 0; i < temp.Count; i++)
|
||||
{
|
||||
for (int j = 0; j < temp[i].unmannedAerialVehicles.Count; j++)
|
||||
{
|
||||
|
||||
if (temp[i].unmannedAerialVehicles[j] != null && temp[i].unmannedAerialVehicles[j].gameObject.activeSelf)
|
||||
if (temp[i].unmannedAerialVehicles[0] != null && temp[i].unmannedAerialVehicles[0].gameObject.activeSelf)
|
||||
{
|
||||
if (temp[i].unmannedAerialVehicles[j].attackTarget == null)
|
||||
if (temp[i].unmannedAerialVehicles[0].attackTarget == null)
|
||||
{
|
||||
temp[i].unmannedAerialVehicles[j].AttAck(attackColliders[i].transform);
|
||||
temp[i].unmannedAerialVehicles[0].AttAck(attackColliders[i].transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -232,22 +232,20 @@ public class UnmannedAerialVehicle : MonoBehaviour
|
|||
{
|
||||
while (attackTarget)
|
||||
{
|
||||
yield return new WaitForSeconds(1f);
|
||||
GameObject obj = Instantiate(shell);
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
GameObject obj = Instantiate(shell, transform);
|
||||
obj.SetActive(true);
|
||||
ShellBoom sb = obj.AddComponent<ShellBoom>();
|
||||
obj.AddComponent<ShellBoom>();
|
||||
ShellBoom sb = obj.GetComponent<ShellBoom>();
|
||||
sb.isPlayer = unmannedAerialVehicleManage.equipmentCommon.isPlayer;
|
||||
sb.attackTarget = attackTarget.gameObject;
|
||||
sb.onShellAttack.AddListener(() =>
|
||||
{
|
||||
AddBao(attackTarget.transform);
|
||||
// 销毁objectToDestroy对象
|
||||
BeAssaulted("攻击到目标");
|
||||
Destroy(sb);
|
||||
});
|
||||
Vector3 direction = obj.transform.position - attackTarget.position;
|
||||
float step = 1 * Time.deltaTime;
|
||||
obj.transform.rotation = Quaternion.LookRotation(direction);
|
||||
obj.transform.position = Vector3.MoveTowards(obj.transform.position, attackTarget.position, step);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue