Jam*_*rke -3 c# unity-game-engine
我在Unity3D引擎中创建一个游戏,我只是编写一些简单的跳跃代码,我遇到了这个问题:
Assets/jumpControll.cs(17,107):错误CS1526:新类型表达式需要()或[].
我不确定如何修复它,因为我确定我说的是跳高是一个浮点数,错误在这一行;
transform.position = new Vector3(transform.position.x, transform.position.y(jumpHeight 3.0f), transform.position.z);
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
using UnityEngine;
using System.Collections;
public class jumpControll : MonoBehaviour {
public bool jump;
public float jumpHeight;
// Use this for initialization
public void SetTransformX (float jumpHeight) {
jumpHeight = 3.0f;
transform.position = new Vector3(transform.position.x, transform.position.y(jumpHeight 3.0f), transform.position.z);
}
// Update is called once per frame
void Update () {
jump = !Input.GetKey(KeyCode.LeftShift);
if (jump == true)
SetTransformX(jumpHeight);
}
}
Run Code Online (Sandbox Code Playgroud)
我想知道是否有人可以帮助我,提前谢谢!
看起来你想在这里做乘法?
transform.position.y(jumpHeight 3.0f)
Run Code Online (Sandbox Code Playgroud)
这在C#中不起作用,请尝试:
transform.position.y * jumpHeight
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
457 次 |
| 最近记录: |