- Home /
What should I do if it shows this message ? Thank you
Assets/BallControl.js(9,19): BCE0020: An instance of type 'UnityEngine.Rigidbody' is required to access non static member 'AddRelativeTorque'.
Answer by Leviatha · Nov 11, 2016 at 10:17 AM
You just need to add a RigidBody from the inspector. Click on the object the script is attacked to -> AddComponent -> RigidBody. Another problem could be the missing declaration of the rigidbody in the script. Open the script and paste this.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class MyCass : MonoBehaviour {
private RigidBody _rb;
void Awake()
{
_rb = GetComponent<RigidBody>();
}
Answer by tanoshimi · Nov 11, 2016 at 09:58 AM
On line 9 of your BallControl script, you make sure that AddRelativeTorque is being called on an instance of a Rigidbody component.
Answer by aditya · Nov 11, 2016 at 10:43 AM
you are telling Unity to apply torque in Air ... Unity is a bit angry just make him happy like this
public Rigidbody rigidbodyReference;
rigidbodyReference.AddRelativeTorque(Vector3.up * 10);
AddRelativeTorque is a member of Rigidbody class
Your answer
Follow this Question
Related Questions
Unexpected "{" and parsing error (roll a ball tutorial) 1 Answer
Build failing- Shader Error in Hidden/PostFX/ 2 Answers
InvalidCastException: Cannot convert from source type to destination type using a Rigidbody2D 2 Answers
Character keeps moving in one direction on its own 4 Answers
How to rotate an object and make it to follow another gameobject? 1 Answer