Salve a tutti ragazzi, sono alle prime armi con Unity e Java, avrei un problemino che non mi sembra così complicato ma non ne vengo a capo. Sto seguendo un tutorial per la creazione di un gioco sidescroller.
In questo script :
codice:
using UnityEngine;using System.Collections;
[RequireComponent(typeof(PlayerPhysics))]
public class PlayerController: MonoBehaviour {
// Player Handling
public float gravity = 20;
public float speed = 8;
public float acceleration = 30;
public float jumpHeight = 12;
private float currentSpeed;
private float targetSpeed;
private Vector2 amountToMove;
private PlayerPhysics playerPhysics;
void Start () {
playerPhysics = GetComponent<PlayerPhysics>();
}
void Update () {
if (playerPhysics.movementStopped) {
targetSpeed = 0;
currentSpeed = 0;
}
//Input
targetSpeed = Input.GetAxisRaw ("Horizontal") * speed;
currentSpeed = IncrementTowards(currentSpeed, targetSpeed, acceleration);
if (playerPhysics.grounded) {
amountToMove.y = 0;
}
//Jump
if(Input.GetButtonDown("Jump")) {
amountToMove.y = jumpHeight;
}
}
amountToMove.x = currentSpeed;
amountToMove.y = gravity * Time.deltaTime;
playerPhysics.Move (amountToMove * Time.deltaTime);
}
// Increse n toward by speed
private float IncrementTowards(float n, float target, float a) {
if (n == target) {
return n;
}
else {
float dir = Mathf.Sign(target - n);
n += a * Time.deltaTime * dir;
return(dir == Mathf.Sign(target - n))? n: target;
}
}
}
Ci sono 7 errori:
1) Unexpected symbol "=" in class, struct, or interface member declaration
2) Unexpected symbol ";" in class, struct, or interface member declaration
3) Unexpected symbol "=" in class, struct, or interface member declaration
4) Unexpected symbol "(" in class, struct, or interface member declaration
5) Unexpected symbol ")" in class, struct, or interface member declaration
6) A namespace can only contain types and namespace declartion
7) Parsing error
Mi dà l'errore su IncrementTowards di "currentSpeed = IncrementTowards(currentSpeed, targetSpeed, acceleration);"
Poi gli = ; ( ) sarebbero di queste stringhe:
amountToMove.x = currentSpeed;
amountToMove.y = gravity * Time.deltaTime;
playerPhysics.Move ( amountToMove * Time.deltaTime );
Son bloccato da due giorni..soluzioni? Grazie in anticipo.