Code: Select all
public class cerealkiller : MonoBehaviour
{
public float moveUnit = 100.0f;
void Start()
{
//QualitySettings.vSyncCount = 0;
//Application.targetFrameRate = 24;
}
void moveMC()
{
Debug.Log("moveUnit original is: " + moveUnit);
moveUnit = 4.0f;
Debug.Log("moveUnit is: "+moveUnit);
float horizontal = Input.GetAxis("Horizontal");
float vertical = Input.GetAxis("Vertical");
Vector2 position = transform.position;
position.x = position.x + moveUnit * horizontal * Time.deltaTime;
position.y = position.y + moveUnit * vertical * Time.deltaTime;
transform.position = position;
}
// Update is called once per frame
void Update()
{
moveMC();
}
}
Das Problem besteht darin, dass die Variable, obwohl ich sie bereits auf 100.0f initialisiert habe, in der Funktion Update() immer als 0.3f ausgegeben wird. Wie im Protokoll unten gezeigt:
Code: Select all
moveUnit original is: 0.3
moveUnit is: 4
Und wenn jemand wie Sir @Selvin hier denkt, dass ich anderen Code habe, der die Variable ändert. Dann haben Sie es falsch erraten, denn derzeit ist dieses Skript das einzige Skript, das ich habe.
Mobile version