- Home /
Instantiate 2D prefab
I have a 2D prefab with a box collider 2d, rigidbody2d and a script. Then when i press "SPACE" i do this :
Rigidbody2D att2;
att2 = Instantiate (att, tra.position,tra.rotation) as Rigidbody2D;
And then, the prefab (att) is instantiated in the scene but in goes up... the y axis change but i don't know why... And then what can i do to move the object to the right or left?? The object is an attack to throw :)
Thank you
There is no reason for this code to change the y-axis of the object. There must be some other script that does that.
I know that there is no reason, but in the script attached to the prefab there is just the function onCollisionEnter2D that destroy this object... So i don't know why this happen...
Answer by darthbator · Jun 10, 2014 at 11:42 PM
Is there a collider at the world location of att? Sounds like once the object is instantiated it realizes it's within the bounds of another collider and it immediately pops out.
Your answer
Follow this Question
Related Questions
how to have a fixed movement using rigidbodies without animations 0 Answers
Rigidbody2D adding force vs modifying velocity for character jump 1 Answer
How do I stop my Player (controlled by RigidBody) stopping after jumping? 0 Answers
Rigidbody velocity slow on mobile device 0 Answers
How to move Character with Addforce? 1 Answer