I am instantiating an prefab arrow and shooting it through a Trigger into the Terrain but neither OnTriggerEnter or OnCollisionEnter trigger at all. The arrow has a Rigidbody attached and is not Kinematic while Flying. I have no idea whats wrong at this point.
The Arrow has a this Script. It is active as soon as the arrow gets Instanciated and does not get deactivated.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EmbededBehavior : MonoBehaviour {
Rigidbody rigidB;
// Use this for initialization
void Start () {
rigidB = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update () {
}
private void OnCollisionEnter(Collision col)
{
Embed();
transform.parent = col.transform;
Debug.Log("OnCollisionEnter");
}
private void OnTriggerEnter(Collider col)
{
Embed();
transform.parent = col.transform;
Debug.Log("OnTriggerEnter");
}
void Embed()
{
transform.GetComponent<ProjectileAddForce>().enabled = false;
rigidB.velocity = Vector3.zero;
rigidB.useGravity = false;
rigidB.isKinematic = true;
}
}