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

You are not connected. Please login or register

Unity Ninja Unity 3D Forum » HELP » Help (General) » Bullet Hole Script Help

Bullet Hole Script Help

Go down  Message [Page 1 of 1]

1 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.

#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);

View user profile http://oneknifegames.weebly.com/

2 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.

View user profile

3 Re: Bullet Hole Script Help on Mon Aug 31, 2015 10:47 am


Member [Lv. 3]
Member [Lv. 3]
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.

View user profile http://jakeaquilina.weebly.com/

Sponsored content

Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum