So I can’t find what has cause this error or to be specific why it is an unexpected symbol… Pls help!! error line: public void SetSpeed(float modifier)…
using UnityEngine;
using System.Collections;
public class PlayerMotor : MonoBehaviour
{
private CharacterController controller;
private Vector3 moveVector;
private float speed = 10.0f;
private float verticalVelocity = 0.0f;
private float gravity = 5.0f;
private float animationDuration = 3.0f;
// Use this for initialization
void Start () {
controller = GetComponent<CharacterController> ();
}
// Update is called once per frame
void Update () {
if (Time.time < animationDuration)
{
controller.Move (Vector3.forward * speed * Time.deltaTime);
return;
}
moveVector = Vector3.zero;
if (controller.isGrounded)
{
verticalVelocity = -0.5f;
}
else
{
verticalVelocity -= gravity * Time.deltaTime;
}
// X - Left and Right
moveVector.x = Input.GetAxisRaw("Horizontal") * speed;
// Y - Up and Down
moveVector.y = verticalVelocity;
// Z - Forward and Backward
moveVector.z = speed;
controller.Move (moveVector * Time.deltaTime);
**public** void SetSpeed(float modifier)
{
speed = 10.0f + modifier;
}
}