Mail.ruПочтаМой МирОдноклассникиВКонтактеИгрыЗнакомстваНовостиКалендарьОблакоЗаметкиВсе проекты

Ошибка CS1061 в коде (С#) 2D игры на Unity

- Ученик (245), на голосовании 3 месяца назад
Помогите пожалуйста, это мой первый код(C#) и игра, можете исправить чтобы было все правильно.
Ошибка :

Assets\Scripts\Player Controller.cs(42,64): error CS1061: 'Vector3' does not contain a definition for 'checkRadius' and no accessible extension method 'checkRadius' accepting a first argument of type 'Vector3' could be found (are you missing a using directive or an assembly reference?)

Код:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
public float speed;
public float jumpForce;
private float moveInput;

private Rigidbody2D rb;

private bool facingRight = true;

private bool isGrounded;
public Transform feetPos;
public float checkRadius;
public LayerMask whatIsGround;


private void Start()
{
rb = GetComponent<Rigidbody2D>();
}

private void FixedUpdate()
{
moveInput = Input.GetAxis("Horizontal");
rb.velocity = new Vector2(moveInput * speed, rb.velocity.y);
if(facingRight == false && moveInput > 0)
{
Flip();
}
else if(facingRight == true && moveInput < 0)
{
Flip();
}
}

private void Update()
{
isGrounded = Physics2D.OverlapCircle(feetPos.position. checkRadius, whatIsGround);

if(isGrounded == true && Input.GetKeyDown( KeyCode.Space ))
{
rb.velocity = Vector2.up * jumpForce;
}

}
void Flip()
{
facingRight = !facingRight;
Vector3 Scaler = transform.localScale;
Scaler.x *= -1;
transform.localScale = Scaler;
}
}
Голосование за лучший ответ
Sergio 2.1 Оракул (67281) 4 месяца назад
 using System.Collections; 
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
public float speed;
public float jumpForce;
private float moveInput;

private Rigidbody2D rb;

private bool facingRight = true;

private bool isGrounded;
public Transform feetPos;
public float checkRadius;
public LayerMask whatIsGround;

private void Start()
{
rb = GetComponent();
}

private void FixedUpdate()
{
moveInput = Input.GetAxis("Horizontal");
rb.velocity = new Vector2(moveInput * speed, rb.velocity.y);
if (facingRight == false && moveInput > 0)
{
Flip();
}
else if (facingRight == true && moveInput < 0)
{
Flip();
}
}

private void Update()
{
isGrounded = Physics2D.OverlapCircle(feetPos.position, checkRadius, whatIsGround);

if (isGrounded == true && Input.GetKeyDown(KeyCode.Space))
{
rb.velocity = Vector2.up * jumpForce;
}
}

void Flip()
{
facingRight = !facingRight;
Vector3 Scaler = transform.localScale;
Scaler.x *= -1;
transform.localScale = Scaler;
}
}
-Ученик (245) 4 месяца назад
Спасибо
Похожие вопросы