unique physics scripting?

Hello, I have some physics scripting questions. How would I make 1 :A magnet that attracts object A 2 :A trampoline like pad that launches object an upwards at a certain velocity? -Thank you

For a magnet, you can apply a force to the affected object at the COM and directed towards the closest point on the magnet to the affected object (or towards the magnet's center if that's suitable). For greater realism you can scale the magnitude of the force based on the distance between the object and the magnet (I don't know the exact relationship, but you should be able to find the formulae for this online).

I'm not sure what the best way to make a 'realistic' trampoline would be, but depending on what you need exactly, applying an upward impulse when the object touches the pad might be a suitable solution.

var collidersInRange : Collider[]; var RelMagnitude ;

function FixedUpdate () {

    collidersInRange = Physics.OverlapSphere(transform.position,50); 
     for(var i : int = 2;i<collidersInRange.length;i++){

      repel(collidersInRange*);*
 *}* 
 *}*
 *else return;*
*```*
*<p>} </p>*
*<p>function repel(col : Collider){</p>*
*```*
*if (col.attachedRigidbody){*
*var trans : Transform = col.attachedRigidbody.transform;*
*if (trans.position.y<20){*
*var relativePosition : Vector3 = ( Vector3(* 
 *(trans.position.x-transform.position.x+0.001),* 
 *(trans.position.y-transform.position.y+0.001),0.0000001*
 *//1/(trans.position.z-transform.position.z+0.001)*
 *) );* 
 *RelMagnitude=relativePosition.magnitude;*
*```*
*<p>Vector3.Normalize (relativePosition);*
 _col.attachedRigidbody.AddForce(1000*relativePosition/(RelMagnitude*RelMagnitude));_ 
*}*
*}*
 *else return;*
 *}</p>*
*<p>This script repels. If you change 1000 to -1000 it will attract. If you change its value you can change the amount of push/pull. The attraction diminishes with the second power of distance as in gravity/electric forces</p>*