为什么我的播放器在与这个平台碰撞时速度会大幅下降



在我的游戏中,我有从a点移动到b点的平台,当玩家出于某种原因降落在平台上时,他的速度会大大降低。

移动平台的代码:

private void Start()
{
isActive = true;
}
void Update()
{
if (isActive == true)
{
transform.position = Vector3.Lerp(pos1, pos2, Mathf.PingPong(Time.time * speed, 1.0f));
}
}`

玩家有一个代码,让他在碰撞时成为平台的孩子,以确保它不会从平台上掉下来。:

if(other.gameObject.CompareTag("MGround"))
{
landEffect.Play();
playerSpeed = 8;
this.transform.parent = other.transform;
isJumping = false;
}

如有任何帮助,我们将不胜感激。

你可以解决这个问题,如果你缓存球员的刚体速度,如果他与平台碰撞,将刚体速度设置为缓存值。刚性车身.速度

// Put this somewhere in your Player script
private Vector3 tmpPlayerVelocity;
void LateUpdate() 
{
tmpPlayerVelocity = yourPlayerRigidbody.velocity;
}
// Put this after your collision code
yourPlayerRigidbody.velocity = tmpPlayerVelocity;

最新更新