问题描述
我有一个固定操纵杆,它通过速度控制运动,我有一个滑动,让我的角色跳跃。
固定操纵杆移动:
requests.exceptions.SSLError: HTTPSConnectionPool(host='<WORKSPACE_ID>.workspace.canadacentral.api.azureml.ms',port=443): Max retries
exceeded with url: /discovery/workspaces/<WORKSPACE_ID> (Caused by SSLError(SSLCertVerificationError(1,'[SSL: CERTIFICATE_VERIFY_Failed] certificate verify Failed: self signed certificate in certificate chain (_ssl.c:1091)')))
void FixedUpdate()
{
v = fixedJoystick.Vertical;
h = fixedJoystick.Horizontal;
if (h >= 0.35f)
{
rb2D.veLocity = new Vector2(runSpeed,rb2D.veLocity.y);
spriteRenderer.flipX = false;
animator.SetBool("Run",true);
}
else if(h <= -0.35f)
{
rb2D.veLocity = new Vector2(-runSpeed,rb2D.veLocity.y);
spriteRenderer.flipX = true;
animator.SetBool("Run",true);
}
else
{
animator.SetBool("Run",false);
}
}
问题:当我移动时,我不能跳跃。因为有两个速度脚本相互冲突(我认为)
如何在没有速度的情况下向对象添加脉冲?
解决方法
1- 使用 AddForce
方法
2- 不要直接设置速度,而是增加或减少它。
rb2D.velocity += new Vector2(runSpeed,rb2D.velocity.y);
如果您想设置最大速度限制,请使用 Vector2.ClampMagnitude