0
I have a problem with a C# code that I am using to make a game in Unity3d Version 5.2.0f3
This Code I picked up on a video of Playing with Nils ( Youtube channel that teaches how to develop games.
There’s an error in setting the player commands, especially now that unity3d has updated and is using Visual Studio 2015 (I don’t know how to use it).
After creating a code in C# to use in my player, presented me the following errors:
This is the Code :
using UnityEngine; // Obrigado por avisar desta linha gamesinsanity
public class Player : MonoBehaviour
{
// The force which is added when the player jumps
// This can be changed in the Inspector window
public Vector2 jumpForce = new Vector2(0, 280);
// Update is called once per frame
void Update()
{
// Jump
if (Input.GetKeyUp("space"))
{
Rigidbody2D.velocity = Vector2.zero;
Rigidbody2D.AddForce(jumpForce);
}
}
}
The error is self-descriptive but to give a solution would need to see other snippets of code. Maybe by watching the video we can help but it would be difficult for us to have to see it to solve your problem. You would probably have to be using a variable with an instance of an object instead of
Rigidbody2D
which is a type. But I can’t say without seeing more context.– Maniero