- Home /
Question by
Hoboreload · Mar 17, 2014 at 12:03 PM ·
error
Error for playerPhysics
Hi, Im only new to unity so I cant find out what is wrong with this code. Thanks if anyone can help me it would be appreciated thanks. The error is:
Assets/Scripts/PlayerController.cs(27,29): error CS1525: Unexpected symbol `playerPhysics'
using UnityEngine; using System.Collections;
[RequireComponent(typeof(PlayerPhysics))] public class PlayerController : MonoBehaviour {
//Player Handling
public float speed = 8;
public float acceleration = 12;
private float currentSpeed;
private float targetSpeed;
private Vector2 amountToMove;
private PlayerPhysics playerPhysics;
void Start () {
playerPhysics = GetComponent<PlayerPhysics>();
}
void Update () {
targetSpeed = Input.GetAxisRaw ("Horizontal") * speed;
currentSpeed = IncrementTowards(currentSpeed, targetSpeed,acceleration);
amountToMove = new Vector2(currentSpeed,0)
playerPhysics.Move(amountToMove * Time.deltaTimes);
}
// Increase n towards target by speed
private float IncrementTowards(float n, float target, float a) {
if (n == target) {
return n;
}
else {
float dir = Mathf.Sign(target - n); // must n be increased or decreased to get closer to target
n += a * Time.deltaTime * dir;
return (dir == Mathf.Sign(target-n))? n: target; // if n has now passed target then return target, otherwise return n
}
}
}
Comment
Your answer
