- Home /
putting gravity with script
Hello! i'm doin a script for adding gravity to a game object.
#pragma strict
var gravity : float = -5;
function Update () {
Transform.Translate (0, "gravity" Time.deltaTime, 0);
}
but i get this error: BCE0020: An instance of type 'UnityEngine.Transform' is required to access non static member 'Translate'.
Thanks a lot!
Answer by MartinCA · Mar 09, 2013 at 08:10 AM
use "transform" instead of "Transform" (lower-cast T).
Transform is the class name (in which case would presume Translate is a static method).
transform is the accessor to the Object's Transform component.
Your answer

Follow this Question
Related Questions
Make character walk on walls defying gravity in a 2D Game 1 Answer
Move object along waypoints, but affected by gravity -1 Answers
How can i make my object like bouncy on finger move? 1 Answer
Gravity is not working no matter what 0 Answers
How can I find the angle of the direction the velocity is pointing? 1 Answer