Место общения программистов C#
Anonymous
Игрок дрожит при столкновении со стеной
Сообщение
Anonymous » 15 июл 2024, 21:46
Когда я прислоняюсь к стене, игрок начинает дрожать.
Код: Выделить всё
using UnityEngine;
public class Movement2 : MonoBehaviour
{
[Header("Movement")]
public float Speed = 4f;
public float jumpPower = 3f;
private Rigidbody2D rb;
private GroundCheck gr;
private float horizontal;
private void Start()
{
rb = GetComponent();
gr = GetComponent();
}
private void Update()
{
horizontal = Input.GetAxisRaw("Horizontal");
if (gr.grounded == true && Input.GetButtonDown("Jump"))
{
rb.velocity = new Vector2(rb.velocity.x, jumpPower);
}
}
private void FixedUpdate()
{
rb.velocity = new Vector2(horizontal * Speed, rb.velocity.y);
}
}
вот как выглядит проблема:
https://imgur.com/a/A32jbxL
Я не знаю, как это исправить .
Подробнее здесь:
https://stackoverflow.com/questions/787 ... ith-a-wall
1721069163
Anonymous
Когда я прислоняюсь к стене, игрок начинает дрожать. [code]using UnityEngine; public class Movement2 : MonoBehaviour { [Header("Movement")] public float Speed = 4f; public float jumpPower = 3f; private Rigidbody2D rb; private GroundCheck gr; private float horizontal; private void Start() { rb = GetComponent(); gr = GetComponent(); } private void Update() { horizontal = Input.GetAxisRaw("Horizontal"); if (gr.grounded == true && Input.GetButtonDown("Jump")) { rb.velocity = new Vector2(rb.velocity.x, jumpPower); } } private void FixedUpdate() { rb.velocity = new Vector2(horizontal * Speed, rb.velocity.y); } } [/code] вот как выглядит проблема: https://imgur.com/a/A32jbxL Я не знаю, как это исправить . Подробнее здесь: [url]https://stackoverflow.com/questions/78751446/player-is-jittering-when-colliding-with-a-wall[/url]