Question by
shadowpuppet · Aug 17, 2020 at 02:44 PM ·
instantiate prefablookrotation
instantiate a decal for broken glass
I have script that works for a raycast hitting glass ( my bullet from gun) to instantiate a bullet hole decal in the glass i just shot.Involves hit.point and normals etc etc. But I can also throw objects where the audio is triggered ( as well as the broken glass decal ) NOT by raycasting but by OnTriggerEnter. How do I get the decal to be the same rotation as the glass I just broke? The decal instantiates in the correct spot but I need the rotation to match the object I hit.
void OnTriggerEnter(Collider other) {
if (other.CompareTag ("glass")) {
audio.PlayOneShot (glass);
Instantiate (glassBreak, transform.position,other.transform.localRotation);
///this is script for raycast bullet hitting glass:
if(hit.transform.gameObject.tag != "glass" && hit.transform.gameObject.name != "JENNY" ){
GameObject bh = Instantiate(bulletHolePrefab, hit.point + (hit.normal * 0.01f), Quaternion.LookRotation(hit.normal)) as GameObject;
bh.transform.parent = hit.transform;
Comment
Your answer