Change Gravity on falling objects

Hello dear unity community!

Please help me out here, I’m going crazy! :slight_smile:

I am making a simple Catch and Fall Game. Now I’m trying to put some “PowerUps” in the Game.

I want to create a Button with an Hourglass on it, if the Player pushes the button all of the falling objects will change the gravity from (-1.8 to -2.0) … this will stay for about 5 seconds and then the normal gravity sets in again.

I already have made an other PowerUp that destroys all of the objects in the scene at a push of a button.

This is the code:

#pragma strict

public var object : GameObject;
var gameObjects : GameObject[];
var points:int;

function FindObject() {
	gameObjects =  GameObject.FindGameObjectsWithTag ("ice");
	 
	for(var i = 0 ; i < gameObjects.length ; i ++)
    Destroy(gameObjects*);*

FindObject2();
}

function FindObject2() {

  • gameObjects = GameObject.FindGameObjectsWithTag (“beach”) ;*

  • for(var i = 0 ; i < gameObjects.length ; i ++)*
    Destroy(gameObjects*);*
    GameObject.Find( “Canvas” ).GetComponent( Punkte ).points += points;
    object.SetActive(false);
    }

How can I instead of destroying the gameobjects change the gravity scale? All of my attempts are not working … I don’t get it.
Appreciate your help already! And if it is possible please use Unityscript, I’m not familiar with c#. :slight_smile:

Well, if your objects have a Rigidbody, you can increase each objects Rigidbody’s force or velocity, or change the entire games world gravity. If your game is a 2D game, then youd be using “Rigidbody2D” or “Physics2D” instead.