Hey guys,
so every time i try to play my 2d platformer it says all errors must be cleared before playing
exact:
Assets/Scripts/PlayerController.cs(17,13): error CS0619: UnityEngine.Component.rigidbody2D' is obsolete:
Property rigidbody2D has been deprecated. Use GetComponent() instead. (UnityUpgradable)’
Assets/Scripts/PlayerController.cs(17,25): error CS1061: Type UnityEngine.Component' does not contain a definition for
velocity’ and no extension method velocity' of type
UnityEngine.Component’ could be found (are you missing a using directive or an assembly reference?)
Here is my code for gravity:
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float moveSpeed;
public float jumpHeight;
void Start () {
}
void Update () {
if(Input.GetKeyDown (KeyCode.UpArrow))
{
rigidbody2D.velocity = new Vector2(0, jumpHeight);
}
if (Input.GetKey (KeyCode.RightArrow))
{
rigidbody2D.velocity = new Vector2(moveSpeed, 0);
}
if (Input.GetKey (KeyCode.LeftArrow))
{
rigidbody2D.velocity = new Vector2(-moveSpeed, 0);
}
}
}