Question by
gesunonviama · Feb 05, 2016 at 04:23 PM ·
scripting problem
UnityEngine.GameObject does not contain a definition for getComponent
using UnityEngine; using System.Collections;
public class Player : MonoBehaviour {
public float speed = 50f;
public float jumpPower = 150f;
public bool grounded;
private Rigidbody2D rb2d;
void Start ()
{
rb2d = GameObject.getComponent<Rigidbody2D> ();
}
void Update ()
{
}
void FixedUpdate()
{
float h = Input.GetAxis ("Horizontal");
rb2d.AddForce (Vector2.right * speed * h);
}
}
Comment