cube damage

im almost done with the gun and its script but the problem is the bullet… it is bulletscript actually… for the mean time my bullet is a cube, i need a psuedo code, idea or an actual code for the cube :slight_smile:

when the cube touches an object(enemy), the enemy’s hp will be decreased

A couple of options, the easiest being SendMessage :

the other way would be to get a reference to the other script (GetComponent), but I think this is all you want.

You need to add a rigidbody to the cube, than make a prefab out of it. You make a bulletscript an add it to your weapon. When you press a button, you initiate the prefab and add a velocity to it. When your bullet touches the enemy, use the collider to check it and decrease the hp.