- Home /
 
transform.position innacurate? [Unity 2D]
Code! :D
 #pragma strict
 #pragma downcast
 var arrow : Transform;
 var pos = new Array();
 var rotation = new Array();
 
 function Start()
  {
  pos = [-0.9, -0.3, 0.3, 0.9];
  rotation = [1, 180, 0, -1];
  var direction;
 
  for(var i = 0; i <= 16; i++)
   {
   direction = Random.Range(0, 4);
   var clone = Instantiate(arrow, Vector3(pos[direction], -2.4, 0), transform.rotation);
   clone.transform.rotation.z = rotation[direction];
   yield WaitForSeconds(1);
   }
  }
 
               So basically, whenever I run this code, when I do Instantiate(), my arrow instantiates, but it is usually off a little bit. The thing is, it only does this when I try to change it to -0.3 and 0.3, and it can offset between -0.3 and -0.4. Hm??? 
Quick commment: Does rigidbody position count for anything?
I figured out that my arrows were bouncing off items offscreen. I cannot fix this until the release the 2D version of IgnoreCollision apparently. Gonna go work out another fix.
Answer by meat5000 · Dec 01, 2013 at 11:08 PM
There is already a 2D Physics Collision Matrix.
Edit -> Project Settings -> Physics 2D
Your answer
 
             Follow this Question
Related Questions
Make object move in a direction depending on where it spawns? (C#) 1 Answer
Shoot an object and have it move based on rotation 1 Answer
teleport in facing direction 1 Answer
How to define directions of a spawned object? 0 Answers
How do I make an object in game face the direction it's traveling while viewing from above? 1 Answer