Rolling ball with controlls: Custom forces, actions or is there better way?

Hey, so I am completely new to Unity, I only know Native Android Dev, Java, PHP, JS and other basic things, but Unity is something new, I want to create small game as I learn it as I believe it’s one of the best ways to learn.

Anyways, I am trying to make a game where user controls bouncing ball to move around screen, so far I got to:
-Ball spawns and only moves along X axis with user controls (left/right), and when user lets the key go it will start stopping and when reaching velocity of less than 0.03 in any direction it’s stopped completely to avoid endless rolling.

Here is the code I wrote:

	void Update () {
		Rigidbody ball = GetComponent<Rigidbody> ();
		Vector3 curr_velocity = ball.velocity;
		if (Input.GetButton ("Horizontal")) {

						//gameObject.transform.Translate(Vector3.right * Input.GetAxis("Horizontal") * 0.05f);
						//gameObject.transform.Rotate(new Vector3(15, 180, 180));
						
						//ball.transform.Translate(Vector3.right * Input.GetAxis("Horizontal") * 0.05f);
						ball.AddForce (Vector3.right * Input.GetAxis ("Horizontal") * 15);
						//ball.transform.Rotate (new Vector3 (15, 180, 180));
				} 			

		else{

//			if(OnCollisionEnter("Line01") == true){
			Vector3 multiplier = new Vector3(0.97f,1,1);
			ball.velocity = Vector3.Scale(curr_velocity, multiplier);
			if(Mathf.Abs(curr_velocity.x) < 0.03){
				ball.velocity = Vector3.zero;
				ball.angularVelocity = Vector3.zero;
			}
//			}
	}
}

Works fine, but I am wondering is this the way it’s done? or is there some kind of way/functionality in Unity physics engine that would do this? or does it always need to have some force applied to make objects move?

If Yes:
How would I make it bounce when ball lands? I don’t want it to look robotic to land and kind of stick to ground straight away, I want it to bounce off a bit until it settles down.

If No:
How is it done then?

Also side question: I want ball coming to stop only when it’s touching ground (platform in my case tagged as “Ground”) but when it goes into free fall it would increase velocity as it falls and then use the velocity to apply various forces to simulate free fall, right now if it’s falling it just sticks and falls straight (since the code says: velocity.x = 0, then stop it completely).

Question: How do I check if my ball is touching ground(a.k.a - Platform or “Ground” )

Thanks a lot, sorry for such basic questions, you will probably see me around asking a lot, I usually google things but sometimes I can’t find decent enough answer.

P.S - Why do I see so many examples online being given in JavaScript but not C#? are most people making games in JS?

Just make a 2d physical material, put 1 in the bounciness and assign it to the 2d collider of the ball. With the grounding just have a floor texture and assign a box collider or any for that matter and it will bounce off its surface infinitely.

Whenever one collider hits another it can be checked within the OnCollisionEnter2D() or if you use trigger OnTriggerEnter2D(). So eg. say from the ground’s perspective I would check if a the ball hits me, assume the ball is named “ball”.

	void OnCollisionEnter2D(Collision2D other){ //other will reference the other collider that hit this one
		if(other.transform.name == "ball"){ 
			print (other.transform.name + " hit me");
		}
	}

if you want it to bounce infinitely in any direction which would be dependent on the force applied then remove gravity.
hope that helps

Forgot to mention: It’s a 3D game but with side camera and ball with ground already has it’s own colliders that’s how ball moves, basically it spawns, drops onto ground then force is just pushing it towards so it rolls.

Also in relation to your collider answer:
Is it possible to attach such script to ball itself? So that I can check condition for braking and only apply braking force when ball is touching ground?

2D are basically pseudo 3D, just remove all the 2D and make a physics material instead of physics material 2d.

yes, just means that you detect “other” as ground or whatever you name the grounding

rigidbody.velocity = Vector3.zero;

Since last time I posted here in the morning, here is where I got:

Pretty happy with my learning progress today, learned lots of things.
I assume it’s not possible to blur out/DOF the background in Free version? would look much better imo if it was possible to blur it out.
Also need to think of solution to bouncing sound (it’s played on collision with object).
Also need to find way to not restart song when person dies and respawns.