Hello I am doing OnCollision and i Have a error:
void OnCollisionEnter2D(Collision2D colInfo)
{
Vector2 v = rigidbody2D.velocity;
//Debug.Log(colInfo.collider.tag);
if(colInfo.collider.tag == "Player")
{
v.y = ((rigidbody2D.velocity.y / 2) + (colInfo.collider.rigidbody.velocity.y / 3));
rigidbody2D.velocity = v;
//float velY = rigidbody2D.velocity.y;
//rigidbody2D.velocity.y = rigidbody2D.velocity.y / 2 + colInfo.collider.rigidbody.velocity.y / 3;
}
}
this is the message of error:
MissingComponentException: There is no
‘Rigidbody’ attached to the “Player01”
game object, but a script is trying to
access it. You probably need to add a
Rigidbody to the game object
“Player01”. Or your script needs to
check if the component is attached
before using it.
UnityEngine.Rigidbody.get_velocity ()
(at
C:/BuildAgent/work/d63dfc6385190b60/artifacts/EditorGenerated/NewDynamics.cs:560)
BallController.OnCollisionEnter2D
(UnityEngine.Collision2D colInfo) (at
Assets/BallController.cs:32)
image with the rigibody2d:
http://www.subirimagenes.net/share.php?img=141010070812349219.png