Unity Ninja Unity 3D Forum
To have exclusive access to all downloads, recourses and links within this forum, a free registered account is required. Just a heads up Wink
Share
Go down
avatar
{SUPER MEMBER}-LV.4
{SUPER MEMBER}-LV.4
Posts : 64
Points : 1855
Rep : 3
Join date : 2013-12-21
Age : 15
Location : USA
View user profilehttp://oneknifegames.weebly.com/

Bullet Hole Script Help

on Thu Jul 02, 2015 6:30 pm
So I have a script that whenever the raycast bullet hits an object, the script plays the indicated in the Inspector. But, I was wondering if there was a way to change it to where is showed an image/texture.

Code:
#pragma strict

var Effect : Transform;
var TheDammage = 100;

function Update () {
   
   var hit : RaycastHit;
   var ray : Ray = Camera.main.ScreenPointToRay(Vector3(Screen.width*0.5, Screen.height*0.5, 0));
   
   if (Input.GetMouseButtonDown(0))
   {
      if (Physics.Raycast (ray, hit, 100))
      {
         var particleClone = Instantiate(Effect, hit.point, Quaternion.LookRotation(hit.normal));
         Destroy(particleClone.gameObject, 2);
         hit.transform.SendMessage("ApplyDammage", TheDammage, SendMessageOptions.DontRequireReceiver);
      }
   }
   
}
avatar
Moderator
Moderator
Posts : 76
Points : 1924
Rep : 16
Join date : 2014-06-02
Age : 15
Location : Milky Way
View user profile

Re: Bullet Hole Script Help

on Fri Jul 17, 2015 10:52 am
Yes, there is. You can use a plane.
You just have to put a texture on the plane.
And if you want to make it so that the plane is a bullet hole, I would create an empty game object and put it in there. The empty game object could be the bullet hole transform. You could do something like make the plane's z be 0.1 in the empty game object so that you can see the full texture when it hits and make the x rotation 90 so that when it hits, it will be flat, like a bullet hole.

Basically, just add a transform variable, like the particle variable, and make it get instantiated.
avatar
Member [Lv. 3]
Member [Lv. 3]
Posts : 45
Points : 1395
Rep : 3
Join date : 2015-08-30
Age : 23
Location : Melbourne
View user profilehttp://jakeaquilina.weebly.com/

Re: Bullet Hole Script Help

on Mon Aug 31, 2015 10:47 am
instantiate a gameobject on the hit.point of the raycast, this will be a plane with your image texture on it. dont forget to set the rotation of the bullet hole to match the gameobject your hitting.
Back to top
Permissions in this forum:
You cannot reply to topics in this forum