How to jump game object using Raycast in Unity


How to make a Game Object Jump on Mouse click using Raycast:
How to make a specific type of game objects jump on mouse click in Unity 3D:

Example Code:

using UnityEngine;

public class InputController : MonoBehaviour {

void Update () {

if (Input.GetMouseButtonUp (0)) {

Vector3 worldMousePsition = Camera.main.ScreenToWorldPoint (new Vector3 (Input.mousePosition.x, Input.mousePosition.y, 100f));

Vector3 direction = worldMousePsition - Camera.main.transform.position;

RaycastHit hit;

if (Physics.Raycast (Camera.main.transform.position, direction, out hit, 100f)) {

Debug.DrawLine (Camera.main.transform.position, hit.point,, 0.5f);

if (hit.rigidbody != null && hit.collider.gameObject.tag == "Ball") {
hit.rigidbody.AddForce (0f, 300f, 0f);
} else {

Debug.DrawLine (Camera.main.transform.position, worldMousePsition,, 0.5f);