Help please. I have a problem with Error CS0120. C#
This is my code. check please.
using UnityEngine; using System.Collections;
public class PlayerControl : MonoBehaviour {
public float force;
public float speed;
private bool jump;
void Update()
{
ControllPc();
if (jump)
{
Jump();
}
}
void ControllPc()
{
if (Input.GetKey(KeyCode.A))
{
transform.Translate(Vector2.right * -speed * Time.deltaTime);
}
if (Input.GetKey(KeyCode.D)) {
transform.Translate(Vector2.right * speed * Time.deltaTime);
}
}
void Jump()
{
Rigidbody2D.AddForce(Vector2.up * force);
jump = false;
}
void OnCollisionStay2D(Collision2D col)
{
if (col.collider.tag == "Platforma")
{
//print(col.collider.name);
if (!jump)
{
jump = true;
//print(jump);
}
}
}
}
Oddly enough in the future you should include the whole message from the console that includes line number, otherwise you're delaying responses.
Answer by Landern · Aug 25, 2015 at 05:51 PM
Line 41, you're using the type Rigidbody2D as static when it is not. You need to use the reference in your script for the currently attached to GameObject which is probably rigidbody2D with a lower case 'r'.
if I use lower case 'r' console writes me a new Error.
Your answer
Follow this Question
Related Questions
How to make a first-person player for my game (like slender or the island demo) 4 Answers
How can I build in Game like the game MineCraft and thank you... 0 Answers
3D Grappling Hook shape skewing *PLZ HELP* 0 Answers
Unity takes around 30 mins to open a new 2d project,Unity takes way too long to open a new project 0 Answers