Gravity using booleans

I would like to turn the gravity on and off in my scene every 5 seconds but can’t figure out the correct syntax using booleans. I’m new so sorry if this is a dumb question. Got the gravity off using the code below but can’t figure out how to time it back on and off forever.

	function OnTriggerEnter (other : Collider) {
		if (other.attachedRigidbody) {
			other.attachedRigidbody.useGravity = false;

Check out the function “Invoke Repeating”

You can call a method to be called every x amount of seconds.

Start the invoke with this method somewhere. It could be in the start part.

InvokeRepeating("Change", 5,5);

This is the cgange method, it will be called in 5 seconds. Read the documentation i gave you.

Void Change()
//obj is the GameObject or if you use it in the script attached to that GameObject which you want to change it's gravity then just use "this"
obj.attachedRigidbody.useGravity = !obj.attachedRigidbody.useGravity;

Sorry if there is something with it’s syntax. I wrote it with my tablet and i am not good with writing code in tablet :slight_smile: