Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bullet Hole Script

Discussion in 'Scripting' started by john4123, Jun 14, 2013.

  1. john4123

    john4123

    Joined:
    Jun 12, 2013
    Posts:
    29
    This is my bullet hole script so far. Does anyone know whats wrong with it? The error im getting is: unknown identifier "Instanciate"

    Code (csharp):
    1. var maxDist : float = 1000000000;
    2. var decalHitWall : GameObject;
    3. var floatInFrontOfWall : float = 0.00001;
    4.  
    5. function Update ()
    6. {
    7.     var hit : RaycastHit;
    8.     if (Physics.Raycast(transform.position, transform.forward, hit, maxDist))
    9.     {
    10.         if(decalHitWall  hit.transform.tag == "Level Parts")
    11.             Instanciate(decalHitWall, hit.point + (hit.normal * floatInFrontOfWall), Quaternion.LookRotation(hit.normal));
    12.     }
    13.    
    14. }
     
  2. wolfhunter777

    wolfhunter777

    Joined:
    Nov 3, 2011
    Posts:
    534
    Instantiate. Spelling error.
     
  3. john4123

    john4123

    Joined:
    Jun 12, 2013
    Posts:
    29
    thanks
     
  4. karwanit

    karwanit

    Joined:
    Dec 30, 2012
    Posts:
    3
    var maxDist: float = 1000000000;
    var decalHitWall : GameObject;
    var floatInFrontOfWall : float = 0.00001;

    function Update ()
    {

    var hit : RaycastHit;

    if(Physics.Raycast(transform.position,transform.forward, hit,maxDist))
    {
    if(decalHitWall && hit.transform.tag == "Level Parts")

    Instantiate(decalHitWall, hit.point + (hit.normal * floatInFrontOfWall), Quaternion.LookRotaion(hit.normal));
    }
    }
     
  5. Deleted User

    Deleted User

    Guest

    This is the version of C# code for everyone who was looking for it, its the same but only translated to c-sharp, hope is usefull
    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class BulletHoleScript : MonoBehaviour {
    5.  
    6.     public float maxDist = 1000000000f;
    7.     public GameObject decalHitWall;
    8.     float floatInFrontOfWall = 0.00001f;
    9.  
    10.     void Update ()
    11.     {
    12.         RaycastHit hit;
    13.         if (Physics.Raycast(transform.position, transform.forward, out hit, maxDist))
    14.         {
    15.             if(decalHitWall && hit.transform.tag == "Level Parts")
    16.             Instantiate(decalHitWall, hit.point + (hit.normal * floatInFrontOfWall), Quaternion.LookRotation(hit.normal));
    17.         }
    18.     }
    19. }
     
    KYT_Jackiie, reddote and smiley_face like this.