0
我想让玩家在乒乓球游戏中控制两个桨。但是,由于某种原因,只有一个桨是可控的,而另一个桨没有任何作用。这是一个桨叶属性栏的图像。右桨没有在团结游戏中移动
这里是代码应与箭头键来控制最右桨。
using UnityEngine;
using System.Collections;
公共类PaddleRight:MonoBehaviour {
public Vector3 playerPosR;
public float paddleSpeed = 1F;
public float yClamp;
void Start()
{
}
// Update is alled once per frame
void Update()
{
float yPos = gameObject.transform.position.y + (Input.GetAxis("Vertical") * paddleSpeed);
if (Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.UpArrow)) {
playerPosR = new Vector3(gameObject.transform.position.x, Mathf.Clamp(yPos, -yClamp, yClamp), 0);
print("right padddle trying to move");
}
gameObject.transform.position = playerPosR;
}
}
我似乎无法找出任何地方为什么它不会移动。请,任何帮助将是真棒,因为我有此时到处检查。谢谢!
好极了!万分感谢! – Luke