- Home /
Anything wrong with my script?
What should I do? The Console says that: "Assets/Scripts/Porta.cs(15,35): error CS0119: Expression denotes a 'type', where a 'variable', 'value' or 'method group' was expected"
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Porta : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (transform.rotation == Vector3(90, 180, 0))
Destroy(GetComponent<Door>());
}
}
Answer by JedBeryll · Sep 07, 2017 at 04:26 AM
Well for one in this line if (transform.rotation == Vector3(90, 180, 0))
you can only compare to a new Vector3(90, 180, 0)
. It has to be new or a previously created vector. Also as Jiak1 said you can only compare quaternion to quaternion and vector to vector. So either check if transform.eulerAngles
equal to the given vector or check if transform.rotation
is equal to Quaternion.Euler(new Vector3(90, 180, 0))
.
Answer by jiak1 · Sep 06, 2017 at 10:27 PM
Rotations are stored as Quaternion's and positions as vector3's you are trying to see if a quaternion is equal to a vector3 when they are two different things.
Your answer
Follow this Question
Related Questions
error keeps looping (smartfox connection) even after I stop testing my game 1 Answer
Where is the problem? 0 Answers
illumination bake problem 1 Answer
OnTriggerEnter firing late? 1 Answer
GetPixel Returning Inaccurate Color 1 Answer