- Home /
How to create an object 2D Js
My game is a top down zombie shooter, and I would like to know how to create an object when i press left arrow, right, up, down. But I don't know how for 2d, I think im suppose to use insantsiat or w/e but I don't know how.
If you want to Instantiate
you should use that method call Instantiate
.
Otherwise please elaborate on your question.
Answer by Inothernews1 · Jan 12, 2014 at 10:51 AM
var object : GameObject;
var left : KeyCode;
var right : KeyCode;
var up : KeyCode;
var down : KeyCode;
function Update(){
if (Input.GetKeyDown("left" || "right" || "up" || "down")){
Instantiate(object, Vector3(0, 0, 0), Quaternion.identity);
}
}
Answer by Inothernews1 · Jan 12, 2014 at 10:51 AM
var object : GameObject;
var left : KeyCode;
var right : KeyCode;
var up : KeyCode;
var down : KeyCode;
function Update(){
if (Input.getKeyDown("left" || "right" || "up" || "down")){
Instantiate(object, Vector2(0, 0), Quaternion.identity);
}
}
Answer by Inothernews1 · Jan 12, 2014 at 10:51 AM
var object : GameObject;
var left : KeyCode;
var right : KeyCode;
var up : KeyCode;
var down : KeyCode;
function Update(){
if (Input.getKeyDown("left" || "right" || "up" || "down")){
Instantiate(object, Vector2(0, 0), Quaternion.identity);
}
}
Your answer
Follow this Question
Related Questions
which better inkscape or Adobe Photoshop or Illustrator for making 2D and 3D sprites 2 Answers
Need help with making to object destroy each other when they meet? 0 Answers
Scene overlapping on real device 1 Answer
Two localscale.transform on the same object 0 Answers
Unity at fedora linux,Unity at fedora. 0 Answers