Answer the question
In order to leave comments, you need to log in
Here is the code. The character does not move. What to do???
public class PlayerController : MonoBehaviour
{
public float SpeedX;
public float SpeedY;
private void FixedUpdate()
{
float moveHorizontal= Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
if (HorizontalMove > 0)
sprt.flipX = false;
else if (HorizontalMove < 0)
sprt.flipX = true;
rb.velocity = new Vector2(moveHorizontal *
SpeedX, moveVertical * SpeedX);
}
}
Answer the question
In order to leave comments, you need to log in
Use the Character Controller component to create a character. The Character Controller has a Move() method.
Vector3 moveVector = new Vector3(0, 0, 0); // Вектор передвижения.
void CharMove(){ // Этот метод в Update
moveVector = Vector3.zero;
moveVector.x = Input.GetAxis("Horizontal") * MoveSpeed;
moveVector.y = Input.GetAxis("Vertical") * MoveSpeed;
CharacterController.Move(moveVector * Time.deltaTime); // Метод движения по вектору передвижения.
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question