- Home /
C# Player Rotation transform error
The Script works fine expect the rotation element. I am a beginner so please go easy on me. here is the script. The Error i'm getting is "Unexpected Symbol 'transform'". Also the script worked without the tag player stuff but was rotation strangely. It looked like the background was rotating instead of the player.
using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour {
public float speed;
// Use this for initialization
void Start () {
}
// Update is called onc e per frame
void Update () {
if (Input.GetKeyDown(KeyCode.Q)) {
gameObject.tag = "Player"
transform.Rotate(Vector3.up, -30 * Time.deltaTime);
}
float h = Input.GetAxisRaw ("Horizontal");
float v = Input.GetAxisRaw ("Vertical");
RaycastHit2D[] Hit = Physics2D.RaycastAll (transform.position, Vector2.up * v, 0.2f);
bool foundObs = false;
foreach (RaycastHit2D thisHit in Hit) {
if(thisHit.collider.gameObject.tag != "Player") {
foundObs = true;
}
}
if (!foundObs) {
transform.Translate(0,v * Time.deltaTime * speed,0);
}
Hit = Physics2D.RaycastAll (transform.position, Vector2.right * h, 0.2f);
foundObs = false;
foreach (RaycastHit2D thisHit in Hit) {
if(thisHit.collider.gameObject.tag != "Player") {
foundObs = true;
}
}
if (!foundObs) {
transform.Translate(h * Time.deltaTime * speed,0,0);
}
}
}
Answer by MakakWasTaken · Sep 27, 2015 at 09:29 PM
You are forgetting to add semicolon (;) at the end. This marks a line ending in most scripting languages.
Answer by JTannhausser · Sep 28, 2015 at 12:09 PM
Line 16: gameObject.tag = "Player" ; // you forgot to put ";"...i think
Your answer
![](https://koobas.hobune.stream/wayback/20220612034944im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
What is wrong with this code for adjusting the walls and players to match the screen size? 1 Answer
Click GUI Button and move the object to another set location 1 Answer
Character moving forwards before pressing anything 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers