Trouble with Instantiation of objects


I am just trying to set up a prototype of spawning a player in a location of his choice. This is the first time I have tryed to Instantiate a object in c# and I am a bit lost after looking at the documentation. At the moment I am trying to make the “player” object spawn in a location, either “Room1Spawn” or “Room2Spawn” after the room has been pressed, my code is shown bellow.

But I am having some errors pop up that I cant quite figure them out:

Assets/Scripts/RoomSpawn.cs(17,57): error CS1061: Type UnityEngine.GameObject' does not contain a definition for position’ and no extension method position' of type UnityEngine.GameObject’ could be found (are you missing a using directive or an assembly reference?)

I assume this is me not declaring something right (have this issue with both position and rotation of both objects). I also have :

Assets/Scripts/RoomSpawn.cs(17,25): error CS1503: Argument #2' cannot convert object’ expression to type `UnityEngine.Vector3’

This backs up my previous theory.

My Code:

using UnityEngine;
using System.Collections;

public class RoomSpawn : MonoBehaviour {

	public GameObject Room1;
	public GameObject Room2;
	public GameObject Room1Spawn;
	public GameObject Room2Spawn;
	public GameObject Player;

	void OnMouseDown (Collider other){
		if (other.gameObject == Room1) {
			Instantiate (Player, Room1Spawn.position, Room1Spawn.rotation);
		if (other.gameObject == Room2) {
			Instantiate (Player, Room2Spawn.position, Room2Spawn.rotation);


Not got access to Unity but try casting that instantiate as a GameObject like this:

(GameObject)Instantiate (Player, Room1Spawn.position, Room1Spawn.rotation);

Can’t test but from memory that should be OK. Or at least give you a different error ;¬)

Ok found out what the issue was that I was storing it as a game object. I looked at some tutorials and they were making the targets as transforms .

public Transform Room1Spawn;

Instantiate (Player, Room1Spawn.position, Room1Spawn.rotation);