error CS0117 UnityEngine.Physics2D PlayerControl
Выбивает ошибку при добавлении строчки в скрипте PlayerControl C# . Ошибка появилась, когда прописал атрибут IsTouchingLayers в Physics2D.IsTouchingLayers
. Have an error when adding a line in the script PlayerControl C #. An error appeared when prescribed attribute IsTouchingLayers в Physics2D.IsTouchingLayers
. Версия (Vesion): Unity3D_4.5.0f6.
using UnityEngine;
using System.Collections;
public class PlayerControl : MonoBehaviour {
public float moveSpeed;
public float jumpForce;
private Rigidbody2D myRigidBody;
public bool grounded;
public LayerMask whatIsGround;
private Collider2D myCollider;
// Use this for initialization
void Start () {
myRigidBody = GetComponent<Rigidbody2D> ();
myCollider = GetComponent<Collider2D> ();
}
// Update is called once per frame
void Update () {
grounded = Physics2D.IsTouchingLayers(myCollider, whatIsGround);
myRigidBody.velocity = new Vector2 (moveSpeed, myRigidBody.velocity.y);
if (Input.GetKeyDown (KeyCode.Space) || Input.GetMouseButtonDown (0))
{
if(grounded){
myRigidBody.velocity = new Vector2 (myRigidBody.velocity.x, jumpForce);
}
}
}
}
Comment