fix on icebolt destroy, tree cutting included

This commit is contained in:
2022-04-07 17:03:21 +03:00
parent aa16a7ad45
commit 5074c55bcf
30 changed files with 4582 additions and 2095 deletions

View File

@@ -104,7 +104,7 @@ public class ActionGestureInteraction : MonoBehaviour
void InstantiateIceBolt(GameObject item)
{
var projectileObj = Instantiate(item, rightHandTransform.position, Quaternion.identity) as GameObject;
var projectileObj = Instantiate(item, rightHandTransform.position, playerCamera.transform.rotation) as GameObject;
projectileObj.GetComponent<Rigidbody>().velocity = (destination - rightHandTransform.position).normalized * projectileSpeed;
}
}

View File

@@ -5,6 +5,23 @@ using UnityEngine;
public class Projectile : MonoBehaviour
{
private bool collided;
Vector3 oldEulerAngles;
private void Start()
{
// Will always be destroyed after 10 seconds.
Destroy(gameObject, 10);
oldEulerAngles = transform.rotation.eulerAngles;
}
private void Update()
{
if (oldEulerAngles != transform.rotation.eulerAngles)
{
Destroy(gameObject);
}
}
private void onCollisionEnter(Collider other)
{
if (other.gameObject.tag != "IceBolt" && other.gameObject.tag != "Player" && !collided)
@@ -13,4 +30,12 @@ public class Projectile : MonoBehaviour
Destroy(gameObject);
}
}
private void onTriggerEnter(Collider other)
{
if (other.gameObject.tag != "IceBolt" && other.gameObject.tag != "Player" && !collided)
{
collided = true;
Destroy(gameObject);
}
}
}