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);
}
}
}