【发布时间】:2018-06-03 21:05:21
【问题描述】:
我制作了一个移动平台,它垂直地从上到下,然后从下到上,依此类推。平台移动正常,但将我的播放器放在上面会使我的播放器不稳定。
当平台从上到下移动时,我的播放器会在上面弹跳。当平台从底部移动到顶部时,它会在途中保持稳定,但当它到达顶部时,我的玩家会自行跳跃。
当我提高平台速度时,情况会变得更糟。我不知道它是由于统一的 2d 物理效应还是什么。我试图通过将反弹设置为 0 并将摩擦设置为 50,在我的玩家对象和平台上使用物理材质 2D,但似乎没有任何效果。有人知道如何禁用移动平台的物理效果吗?以下是我的移动平台代码:
public class BrickMoveVErtical : MonoBehaviour {
public Vector3 positionOne;
public Vector3 positiontwo;
public Vector3 nextposition;
/*Empty object is already made on unity editor and its parent of platform(Plank) and other
empty object "pointB". Point "B" is already mapped on editor and platform is set to go from
its original pos to point B */
public Transform plankTranform;
public Transform positionBTransform;
public float speed;
// Use this for initialization
void Start () {
positionOne = plankTranform.localPosition;
positiontwo = positionBTransform.localPosition;
nextposition = positiontwo;
}
// Update is called once per frame
void Update () {
move();
}
private void move() {
plankTranform.localPosition = Vector3.MoveTowards(plankTranform.localPosition,nextposition,Time.deltaTime*speed);
if(Vector3.Distance(plankTranform.localPosition,nextposition)<0.1)
{ changeMovementPlank(); }
}
void changeMovementPlank() {
nextposition = nextposition != positionOne ? positionOne : positiontwo;
}
}
【问题讨论】: