For my upcoming (heavily modified) Tetris game I need to break down the dropping blocks into bits. I figured to make a prefab of the colored (1x1) blocks, drop one on the screen (BEHIND the camera reach) and then use Instantiate to clone it. For the easy of testing I'm using the press of N to create it on a hard-coded spot.
using UnityEngine;
using System.Collections;
public class TetrisBits : MonoBehaviour
{
public Transform myObject;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if (Input.GetKey(KeyCode.N) && Input.GetKeyDown(KeyCode.N))
{
Instantiate(myObject, new Vector3(176,261,1),myObject.rotation);
}
}
}
Well, code works, but it's not created on (176,261,1) in the anchor where the prefab sprite resides, but instead it's on those coordinates in the MAIN camera (and thus waaay off where I want it
). Now I'm wondering how I can tell the object to appear under the anchor it's parent is instead of the clone popping up on the main window. Also worth to note that
myObject.rotation is not working as 'anchor' as the
tutorial on the Unity site tells me.