- Home /
Help,don't know why script not working!
I put in this script and a bunch of errors came up, what did I do wrong!!!
using UnityEngine; using System.Collections;
public class Example : MonoBehaviour { public float gravity = 1f; public float gchange = 0f;
void Update()
{
if(gchange < gravity);
{
gameObject.rigidbody.useGravity(false);
}
}
}
For future posts:
Please format your code. After pasting your code in, select your code and use the 101/010 button.
Please include a copy from the console of the error you are gettng.
Please pick a title that describes the specific problem you are having. For example in this case, you might use: "`UnityEngine.Rigidbody.useGravity' cannot be used as method or delegate".
As for your error @Lo0Nuhtik spotted it. Take a close look at the sample code at the link.
Answer by Romano · Mar 26, 2014 at 02:37 AM
Hiya. What you need here is useGravity = false; instead of useGravity(false).
Answer by Sildaekar · Mar 26, 2014 at 03:15 AM
You had a semicolon in the if statement, and useGravity is a static variable (it needs to have = not ())
void Update()
{
if(gchange < gravity)
{
gameObject.rigidbody.useGravity=false;
}
}
Your answer
Follow this Question
Related Questions
Turning on and off Rigidbody programmatically? 3 Answers
Flip gravity 0 Answers
Why does gravity's vector3 act so weird? 1 Answer
Re-orienting Player after changing direction of Gravity 0 Answers
Gravity Direction Change 4 Answers