# Help with SendMessage?

**URL:** https://discussions.unity.com/t/help-with-sendmessage/184873
**Category:** Questions & Answers
**Created:** [March 30, 2017, 12:06am UTC](https://discussions.unity.com/t/help-with-sendmessage/184873 "2017-03-30T00:06:15Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![cmcmains](https://avatars.discourse-cdn.com/v4/letter/c/8dc957/32.png) [@cmcmains](https://discussions.unity.com/u/cmcmains)
#### Post date: [March 30, 2017, 12:06am UTC](https://discussions.unity.com/t/help-with-sendmessage/184873/1 "2017-03-30T00:06:15Z")

</div>

I’m trying to use SendMessage to tell an object that it has been hit by a ray. Basically, I have two attacks. I have a short hit and a long hit, each need to do different damage. How do I send the amount of damage that it needs to apply to the receiver?

---

<div class="post-metadata">

### Author: ![TeohRIK](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/teohrik/32/485259_2.png) [@TeohRIK](https://discussions.unity.com/u/TeohRIK)
#### Post date: [March 30, 2017, 1:36am UTC](https://discussions.unity.com/t/help-with-sendmessage/184873/2 "2017-03-30T01:36:01Z")

</div>

Lets say your receiver have a Damage function with a float parameter

```
void Damage(float damageValue){

     hp -= damangeValue;

}

```

Then on the other side, when the raycast hit the object then Call the SendMessage function

```
float damangeValue = 10f;

RaycastHit hit;

if(Physics.Raycast(gun.position, gun.forward, out hit, rayDistance)){
     
     hit.collider.gameObject.SendMessage("Damage", damangeValue);

}

```
