So I am looking to freeze rotation in the Y axis on a Rigidbody 2D. I'm not sure how to set this in my code. This is what I have so far, can you point out my errors?
public class PlayerMovement : MonoBehaviour
{
public float speed;
public float height;
GameObject Player;
RigidbodyConstraints pos;
Transform P;
// Update is called once per frame
void OnAwake()
{
Player = GameObject.Find ("Player");
pos = RigidbodyConstraints.FreezeRotationY;
Rigidbody2D. = pos;
}
void FixedUpdate ()
{
if (Input.GetButton ("Horizontal"))
{
transform.Translate (Vector3.right * speed * Time.deltaTime);
}
if( Input.GetButton("Left"))
{
transform.Translate (Vector3.left * speed * Time.deltaTime);
}
if (Input.GetButton ("Jump"))
{
transform.Translate (Vector3.up * height * Time.deltaTime);
}
}
}