- Home /
I need help with a max.x parser error
using UnityEngine, using System.Collections;
public class PlayerControl : MonoBehaviour { // Use this for initialization void Start () { }
// Update is called once per frame
void Update ()
{
float x = Input.GetAxisRaw ("Horizontal");//the value will be -1, 0, or 1 (for left, no input, and right)
float y = Input.GetAxisRaw ("Vertical");//the value will be -1, 0, or 1 (for down, no input, and up)
//now based on the input we compute a direction vector, and we normalize it to get a unit vector
Vector2 direction = new Vector2 (x, y).normalized;
//now we call the function that computes and sets the player's position
Move (direction);
}
void Move(Vector2 direction)
{
//Find the screen limits to the player's movement (left, right, top, and bottom edges of the screen)
Vector2 min = Camera.main.ViewportToWorldPoint (new Vector2 (0, 0)); //this is the bottom-left point (corner) of the screen
} Vector2 max = Camera.main.ViewportToWorldPoint (new Vector2 (1, 1)); //this is the top-right point (corner) of the screen
}
//Find how far the player sprite can go without going out
max.x = max.x - 0.500f;//subtract the player's sprite half width
min.x = min.x + 0.500f;//add the player's sprite half width
max.y = max.y - 0.550f;//subtract the player's sprite half height
min.y = min.y + 0.550f;//add the player's sprite half height
//get the players current position
Vector2 pos = transform.position;
//Calculate the new position
pos += Direction * speed * Time.deltaTime;
//Make sure the new position is not outside the screen
pos.x = Mathf.Clamp (pos.x, min.x, max.x);
pos.y = Mathf.Clamp (pos.y, min.y, max.y);
//Update the player's position
transform.position = pos
}
}
}
Hello I have no I de how to ask or fix this can anybody help?
Answer by allenallenallen · Aug 09, 2015 at 04:37 PM
Here, I took a screenshot of your code and circled the extra curly brackets in red. Delete them.
Thank you," but now it says end of file" problem (CS1525 )
Always make sure there are an even number of brackets. I only told you to delete the brackets based on what you showed me. You might have other codes that you didn't fully copy. So go check if there are even number of brackets and that you're ending the whole script with a closed curly bracket.
I fixed the first 2 but know it has a problem with the speed time deltaTime
What I said. Curly brackets. $$anonymous$$ake sure there's one } at the end of the script. And make sure there are an even number of them.
Your answer
Follow this Question
Related Questions
Shader Compile Error, Parsing 1 Answer
Error CS8025 1 Answer
Strange Parsing Error 1 Answer
Parsing error -.- 2 Answers
Unexpected "{" and parsing error (roll a ball tutorial) 1 Answer