User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active

Basic Bullet Hole

The following snippet shows how to implement a simple bullet hole creation component with EasyDecal.

using UnityEngine;
using ch.sycoforge.Decal;
/// <summary>
/// Demo class for runtime decal placement.
/// </summary>
public class DynamicDemo : MonoBehaviour 
    public EasyDecal DecalPrefab_A;
    // Update is called once per frame
    void Update () 
        if (Input.GetMouseButtonUp(0))
            // Shoot a ray thru the camera starting at the mouse's current screen space position
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            // Check if ray hit something
            if (Physics.Raycast(ray, out hit, 200))
                // Draw a line along the projection axis for visalizing the projection process.
                Debug.DrawLine(ray.origin, hit.point,;
                // Instantiate the decal prefab according the hit normal
                EasyDecal.ProjectAt(DecalPrefab_A.gameObject, hit.collider.gameObject, hit.point, hit.normal);



Sycoforge Technology is the plug-in publishing arm of the Sycoforge Game Studio.

Copyright © 2020 by Sycoforge Technologies. All Rights Reserved.