strange error messages

hi there,

can someone explain to me what this error message is all about:
The type ‘UnityEngine.Texture2D’ does not have a visible constructor that matches the argument list ‘(Object, Object)’.

this is the line where the error happens:

var _maze_width=50;
var _maze_height=50;
var maze = new Texture2D(_maze_width, _maze_height);

any ideas? i just dont get it… there are other similar problems for example in this lines:

for(i=0;i<_maze_width;i++)
{
	for(j=0;j<_maze_height;j++)
	{
		maze.SetPixel(i,j,Color.black);
	}
}

gives me this:
BCE0051: Operator ‘<’ cannot be used with a left hand side of type ‘int’ and a right hand side of type ‘Object’.

another problem is this:

			if (maze.GetPixel(i,j).r>0.5) 
			{
				//wand
				pos = Vector3((i-this._maze_width/2)*_size, 1,( j-this._maze_height/2)*_size);
				
				var wand : GameObject  = Instantiate(wandObjekt);
				wand.transform.position = pos;
				wand.transform.localScale = Vector3(_size,_wall_height,_size);
			}

wandObjekt is set at the top of the script :
var wandObjekt : Transform;

→ BCE0022: Cannot convert ‘UnityEngine.Object’ to ‘UnityEngine.GameObject’.

thanks for any help.
cheers,
ello

For the first second errors, you might need to strongly type your variables:

var _maze_width : int = 50;
var _maze_height : int = 50;

Sorry, I gotta run, can’t look at the third. :slight_smile:

Looking at your third problem now, I think this might help:

var wand : GameObject = Instantiate(wandObjekt) as GameObject;

thank you, that did the trik :slight_smile: but now the following appears:

whith the line:
→ wand.transform.position = pos;

wand is null.

Try instead:

var wand : GameObject = GameObject(Instantiate(wandObjekt));

Slight difference, but it will throw a different error if “wandObjekt” isn’t a GameObject. (What is wandObjekt anyway?)

thanks for your reply. wandObject is a linked prefab (var wandObject : Transform)

thats the problem then. its defined as transform, so Instantiate will return a transform too, to which you would cast it, to then use .gameObject to get the game object of this transform

thank you! that did it :slight_smile: