physics bouncing and raycasting

I’ve been successful at creating a rigidbody that has the bouncy material attached to it. The problem is I’ve changed a bunch of settings like friction to 0 and bounce to 1 but I can’t get my object to constantly bounce forever. Also I’m not sure how I would use raycasting to send the object that’s bouncing towards the area I clicked.

So basically I’m trying to create a constantly bouncing object and when you click on a certain part of the ground it will apply force to launch it towards that spot.

Also I’m using javascript.

Hi jessee03. I shall post a simple script which uses force - and which I feel is the best way of sending an object off in the direction desired. I am not expecting this to be a correct answer - but hey I am yet to help anyone and I have a calling to try :slight_smile:

var speed:int =5; //Set the speed you want.

function OnControllerColliderHit(hit:ControllerColliderHit){ //note the controller use

	if(hit.gameObject.tag == "ball") { // crate a tag and assign it to the ball
	
		Debug.Log ("We hit the ball"); //a debug test for the collision
		hit.rigidbody.AddForce(transform.up * speed); //tell the ball to go up at // the * speed var
																}
}

As you can see, I am using the firstpersoncontroller standard asset - which comes with controls, physics etc. (and so you may delete the main camera from your scene). I created a new tag, ball, and then assigned that tag to my ball :slight_smile: I then dropped the script onto my firstpersoncontroller and boosh! When I contact the ball - it is sent off in my chosen direction and I see debug text.

I am hoping this will help in some way, it seems relevant. When it comes to having the ball for example go to the area you are clicking, I am not yet advanced to give you that script - perhaps you can edit this and find something else somewhere or maybe others can edit it or give you something better.

When it comes to getting a bouncing ball, check your gravity values and also the materials you have assigned. Also perhaps assign physics materials to your surface? If set the ground to bouncey as well it may help. Good luck!