Search Unity

HurricaneVR Platform, How to detect Collision of Gameobject with a bullet?

Discussion in 'Game Design' started by robotrods, Jun 24, 2022.

  1. robotrods

    robotrods

    Joined:
    May 10, 2020
    Posts:
    2
    Hello, I am a novice working on my first FPS game, for Oculus Quest 2, using the Hurricane VR platform. To test if the HVR prefabs pistols bullets, where being detected by a Rigidbody, in the game, I created a sphere, and then added a rigidbody, and the script below. I used a sphere purposely, so I could visually see if the bullet projectiles, shot using the HVR pistol, would move the sphere, which it does. Then, since I do not know the tag name, or name of the bullet that is colliding with my sphere, I tested it with this script and another similar to this one, that tested for tags, instead of the name of the colliding object. I have not been able to detect the colliding projectile, that comes out of my HVR pistol. Any help on detecting this object, or any ideas, would be highly appreciated.

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class sphereCollDetector : MonoBehaviour
    4. {
    5.     // link rigidbody from game object, to this
    6.     public Rigidbody RB;
    7.  
    8.     private void OnCollisionEnter(Collision collision)
    9.     {
    10.         Debug.Log("onCollisionEnter: " + collision.ToString());
    11.     }
    12.  
    13.     private void OnCollisionExit(Collision collision)
    14.     {
    15.         Debug.Log("onCollisionExit: " + collision.ToString());
    16.     }
    17.  
    18.     private void OnParticleTrigger()
    19.     {
    20.         Debug.Log("-OnParticleTrigger-");
    21.     }
    22.  
    23.     private void OnTriggerEnter(Collider other)
    24.     {
    25.         Debug.Log("OnTriggerEnter: " + other.name.ToString());
    26.     }
    27.     private void OnTriggerExit(Collider other)
    28.     {
    29.         Debug.Log("OnTriggerExit: " + other.name.ToString());
    30.     }
    31.  
    32.     public void OnParticleCollision(GameObject other)
    33.     {
    34.         Debug.Log("OnParticleCollision: " + other.name.ToString());
    35.     }
    36.  
    37. }