# Code not being run - (beginner!)

**URL:** <https://discussions.unity.com/t/code-not-being-run-beginner/653644>\
**Category:** Scripting\
**Tags:** Scripting\
**Created:** [January 29, 2017, 5:20am UTC](https://discussions.unity.com/t/code-not-being-run-beginner/653644 "2017-01-29T05:20:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Govind-Krishna](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/govind-krishna/32/391121_2.png) [@Govind-Krishna](https://discussions.unity.com/u/Govind-Krishna)\
**Post date:** [January 29, 2017, 5:20am UTC](https://discussions.unity.com/t/code-not-being-run-beginner/653644/1 "2017-01-29T05:20:17Z")

</div>

Hi all,

Been watching some tutorials and trying out this classic pong game and I stuck at this place where the ball is supposed to gain speed as it collides on the bat. However, the code isn’t working (though there are no errors).

So what I have done is written the function to gain speed as the ball hits the bat and its after the update code block. The script is component of the Bat gameOBJ

I have declared a variable **ballCollisionSpeed** to be equal to 5.

```csharp
  void onCollisionExit2D(Collision2D ballTouch)

 {
       ballTouch.rigidbody.velocity = new Vector2( ballTouch.rigidbody.velocity.x * 2.1f, ( ballTouch.rigidbody.velocity.y + ballCollisonSpeed) * Time.deltaTime);
 
Debug.Log(ballTouch.rigidbody.velocity);       
Debug.Log("COLLIDED");
print("I have collided");
    }

```

The ball not only slows down after gradually (opposite of what I want), but none of Debug.Log shows up on the console, nor does the print. I tried re-arranging the code, setting it up in the ball gameOBJ but nothing seems to work. It’s as if the code is not being read at all. As I commented out the code and the game doesn’t seem to be affected.

Thanks for help & regards.  
-G

---

<div class="post-metadata">

**Author:** ![Kiwasi](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/kiwasi/32/351502_2.png) [@Kiwasi](https://discussions.unity.com/u/Kiwasi)\
**Post date:** [January 29, 2017, 5:25am UTC](https://discussions.unity.com/t/code-not-being-run-beginner/653644/2 "2017-01-29T05:25:30Z")

</div>

Capital O in OnCollision

---

<div class="post-metadata">

**Author:** ![asperatology](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@asperatology](https://discussions.unity.com/u/asperatology)\
**Post date:** [January 29, 2017, 6:03am UTC](https://discussions.unity.com/t/code-not-being-run-beginner/653644/3 "2017-01-29T06:03:51Z")

</div>

Adding to this, all MonoBehaviour methods all start with capital letters.

---

<div class="post-metadata">

**Author:** ![Govind-Krishna](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/govind-krishna/32/391121_2.png) [@Govind-Krishna](https://discussions.unity.com/u/Govind-Krishna)\
**Post date:** [January 29, 2017, 7:12am UTC](https://discussions.unity.com/t/code-not-being-run-beginner/653644/4 "2017-01-29T07:12:16Z")

</div>

I feel so dumb right now…

Thank you so much guys, that helped and it worked. I have been trying to figure it out from 2-3 hours.
