fix on icebolt destroy, tree cutting included
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user