How to create floating platform?

I have a platform which is positioned above ground and currently has a collider and rigidbody attached. I would like the platform to lower a little when the player jumps on and then raise again when player jumps off.

I would like to be able to control the amount that the platform raises/lowers.

What is the best way of doing this?

I tried using the Spring Joint but got completely lost.

Spring Joint is a good solution (let the Connected Rigidbody field blank, so the spring will be connected to the world). If the player is a CharacterController, use OnControllerColliderHit to apply a force (a pseudo weight) to the platform:

var weight = 10.0; // fake "weight"

function OnControllerColliderHit(hit: ControllerColliderHit){
	if (hit.rigidbody){
		hit.rigidbody.AddForce(-hit.normal * weight);
	}
}

You can tweak the weight and the Spring Joint spring parameter to get the desired effect (freeze rotations and adjust damp to get a better behaviour).

As of 5.6, I’ve found that it’s better to use an Area Effector place under the platform. I think it’s a little easier to control and setup compared to a Spring Joint.