Синтаксис:
Используется csharp
using UnityEngine;
using System.Collections;
public class CharController : MonoBehaviour
{
public Rigidbody2D rb2d;
public float playerSpeed;
public float jumpPower;
public int directionInput; //для чего это поле?
public bool groundCheck; //для чего это поле?
public bool facingRight = true; //для чего это поле?
void Start()
{
rb2d = GetComponent<Rigidbody2D>();
}
void Update()
{
if ((directionInput < 0) && (facingRight))
{
Flip();
}
if ((directionInput > 0) && (!facingRight))
{
Flip();
}
groundCheck = true;
}
void FixedUpdate()
{
rb2d.velocity = new Vector2(playerSpeed * directionInput, rb2d.velocity.y); //что значит velocity?
}
public void Move(int InputAxis) //этот метод не вызывается. для чего он нужен?
{
directionInput = InputAxis;
}
public void Jump(bool isJump)
{
isJump = groundCheck;
if (groundCheck)
{
rb2d.velocity = new Vector2(rb2d.velocity.x, jumpPower);
}
}
void Flip()
{
facingRight = !facingRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
}
using System.Collections;
public class CharController : MonoBehaviour
{
public Rigidbody2D rb2d;
public float playerSpeed;
public float jumpPower;
public int directionInput; //для чего это поле?
public bool groundCheck; //для чего это поле?
public bool facingRight = true; //для чего это поле?
void Start()
{
rb2d = GetComponent<Rigidbody2D>();
}
void Update()
{
if ((directionInput < 0) && (facingRight))
{
Flip();
}
if ((directionInput > 0) && (!facingRight))
{
Flip();
}
groundCheck = true;
}
void FixedUpdate()
{
rb2d.velocity = new Vector2(playerSpeed * directionInput, rb2d.velocity.y); //что значит velocity?
}
public void Move(int InputAxis) //этот метод не вызывается. для чего он нужен?
{
directionInput = InputAxis;
}
public void Jump(bool isJump)
{
isJump = groundCheck;
if (groundCheck)
{
rb2d.velocity = new Vector2(rb2d.velocity.x, jumpPower);
}
}
void Flip()
{
facingRight = !facingRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}
}