FragMate CommunityLog in

FragMate - Software and Game Developer Community, including Resources, Forums, Marketplace & More.


descriptionBullet Hole Script Help

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

-One Knife Games

descriptionRe: Bullet Hole Script Help

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.

descriptionRe: Bullet Hole Script Help

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.
Permissions in this forum:
You cannot reply to topics in this forum